wxPython Merge #2 of 2.4 branch --> HEAD (branch tag: wxPy_2_4_merge_2)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21593 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import sys
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
import wxPython.lib.wxpTag
|
||||
import wx # This module uses the new wx namespace
|
||||
import wx.html
|
||||
import wx.lib.wxpTag
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyAboutBox(wxDialog):
|
||||
class MyAboutBox(wx.Dialog):
|
||||
text = '''
|
||||
<html>
|
||||
<body bgcolor="#AC76DE">
|
||||
@@ -29,36 +29,40 @@ sit back and enjoy. Be sure to take a peek at the source code for each
|
||||
demo item so you can learn how to use the classes yourself.</p>
|
||||
|
||||
<p><b>wxPython</b> is brought to you by <b>Robin Dunn</b> and<br>
|
||||
<b>Total Control Software,</b> Copyright (c) 1997-2002.</p>
|
||||
<b>Total Control Software,</b> Copyright (c) 1997-2003.</p>
|
||||
|
||||
<p>
|
||||
<font size="-1">Please see <i>license.txt</i> for licensing information.</font>
|
||||
</p>
|
||||
|
||||
<p><wxp class="wxButton">
|
||||
<p><wxp module="wx" class="Button">
|
||||
<param name="label" value="Okay">
|
||||
<param name="id" value="wxID_OK">
|
||||
<param name="id" value="ID_OK">
|
||||
</wxp></p>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
def __init__(self, parent):
|
||||
wxDialog.__init__(self, parent, -1, 'About the wxPython demo',)
|
||||
html = wxHtmlWindow(self, -1, size=(420, -1))
|
||||
wx.Dialog.__init__(self, parent, -1, 'About the wxPython demo',)
|
||||
html = wx.html.HtmlWindow(self, -1, size=(420, -1))
|
||||
py_version = sys.version.split()[0]
|
||||
html.SetPage(self.text % (wx.__version__, py_version))
|
||||
btn = html.FindWindowById(wxID_OK)
|
||||
html.SetPage(self.text % (wx.VERSION_STRING, py_version))
|
||||
btn = html.FindWindowById(wx.ID_OK)
|
||||
btn.SetDefault()
|
||||
ir = html.GetInternalRepresentation()
|
||||
html.SetSize( (ir.GetWidth()+25, ir.GetHeight()+25) )
|
||||
self.SetClientSize(html.GetSize())
|
||||
self.CentreOnParent(wxBOTH)
|
||||
self.CentreOnParent(wx.BOTH)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = wx.PySimpleApp()
|
||||
dlg = MyAboutBox(None)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
app.MainLoop()
|
||||
|
||||
|
79
wxPython/demo/AnalogClockWindow.py
Normal file
79
wxPython/demo/AnalogClockWindow.py
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.analogclock import AnalogClockWindow
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
c1 = AnalogClockWindow(self)
|
||||
c1.SetBackgroundColour("RED")
|
||||
c1.SetHandsColour("BLUE")
|
||||
c1.SetTickMarkColours("WHITE")
|
||||
|
||||
c2 = AnalogClockWindow(self)
|
||||
c2.SetBackgroundColour("WHITE")
|
||||
c2.SetHandsColour("RED")
|
||||
c2.SetTickMarkColours("BLUE")
|
||||
|
||||
c3 = AnalogClockWindow(self)
|
||||
c3.SetBackgroundColour("BLUE")
|
||||
c3.SetHandsColour("WHITE")
|
||||
c3.SetTickMarkColours("RED")
|
||||
|
||||
c4 = AnalogClockWindow(self, style=wxRAISED_BORDER)
|
||||
c4.SetTickMarkStyle(AnalogClockWindow.TICKS_CIRCLE)
|
||||
|
||||
c5 = AnalogClockWindow(self)
|
||||
c5.SetTickMarkStyle(AnalogClockWindow.TICKS_NONE)
|
||||
|
||||
c6 = AnalogClockWindow(self, style=wxSUNKEN_BORDER)
|
||||
|
||||
|
||||
# layout the clocks in a grid
|
||||
gs = wxGridSizer(2, 3, 4, 4)
|
||||
gs.Add(c1, 0, wxEXPAND)
|
||||
gs.Add(c2, 0, wxEXPAND)
|
||||
gs.Add(c3, 0, wxEXPAND)
|
||||
gs.Add(c4, 0, wxEXPAND)
|
||||
gs.Add(c5, 0, wxEXPAND)
|
||||
gs.Add(c6, 0, wxEXPAND)
|
||||
|
||||
# put it in another sizer for a border
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
sizer.Add(gs, 1, wxEXPAND|wxALL, 10)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>AnalogClockWindow</center></h2>
|
||||
|
||||
This is a nice little clock class that was contributed to by several
|
||||
members of the wxPython-users group.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -127,3 +127,10 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -90,3 +90,10 @@ help into your applicaiton using the wxSimpleHelpProvider class.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -206,11 +206,38 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This demo shows some examples of data transfer through clipboard or drag and drop. In wxWindows, these two ways to transfer data (either between different applications or inside one and the same) are very similar which allows to implement both of them using almost the same code - or, in other words, if you implement drag and drop support for your application, you get clipboard support for free and vice versa.
|
||||
|
||||
At the heart of both clipboard and drag and drop operations lies the wxDataObject class. The objects of this class (or, to be precise, classes derived from it) represent the data which is being carried by the mouse during drag and drop operation or copied to or pasted from the clipboard. wxDataObject is a "smart" piece of data because it knows which formats it supports (see GetFormatCount and GetAllFormats) and knows how to render itself in any of them (see GetDataHere). It can also receive its value from the outside in a format it supports if it implements the SetData method. Please see the documentation of this class for more details.
|
||||
|
||||
Both clipboard and drag and drop operations have two sides: the source and target, the data provider and the data receiver. These which may be in the same application and even the same window when, for example, you drag some text from one position to another in a word processor. Let us describe what each of them should do.
|
||||
|
||||
overview = """<html><body>\
|
||||
This demo shows some examples of data transfer through clipboard or
|
||||
drag and drop. In wxWindows, these two ways to transfer data (either
|
||||
between different applications or inside one and the same) are very
|
||||
similar which allows to implement both of them using almost the same
|
||||
code - or, in other words, if you implement drag and drop support for
|
||||
your application, you get clipboard support for free and vice versa.
|
||||
<p>
|
||||
At the heart of both clipboard and drag and drop operations lies the
|
||||
wxDataObject class. The objects of this class (or, to be precise,
|
||||
classes derived from it) represent the data which is being carried by
|
||||
the mouse during drag and drop operation or copied to or pasted from
|
||||
the clipboard. wxDataObject is a "smart" piece of data because it
|
||||
knows which formats it supports (see GetFormatCount and GetAllFormats)
|
||||
and knows how to render itself in any of them (see GetDataHere). It
|
||||
can also receive its value from the outside in a format it supports if
|
||||
it implements the SetData method. Please see the documentation of this
|
||||
class for more details.
|
||||
<p>
|
||||
Both clipboard and drag and drop operations have two sides: the source
|
||||
and target, the data provider and the data receiver. These which may
|
||||
be in the same application and even the same window when, for example,
|
||||
you drag some text from one position to another in a word
|
||||
processor. Let us describe what each of them should do.
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -38,3 +38,11 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = fancytext.__doc__.replace("<", "<")
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -74,3 +74,12 @@ overview = """<html><body>
|
||||
""" % ( FileBrowseButton.__doc__,
|
||||
FileBrowseButtonWithHistory.__doc__ ,
|
||||
str(DirBrowseButton.__doc__) )
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -24,7 +24,7 @@ class TestPanel(wxPanel):
|
||||
row = wxBoxSizer(wxHORIZONTAL)
|
||||
row.Add(s1, 0, wxALL, 5)
|
||||
row.Add(self.lb1, 0, wxALL, 5)
|
||||
row.Add(self.txt, 0, wxALL, 5)
|
||||
row.Add(self.txt, 0, wxALL|wxADJUST_MINSIZE, 5)
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
sizer.Add(row, 0, wxALL, 30)
|
||||
@@ -32,13 +32,27 @@ class TestPanel(wxPanel):
|
||||
self.Layout()
|
||||
|
||||
self.lb1.SetSelection(0)
|
||||
self.OnSelect(None)
|
||||
wxFutureCall(300, self.SetTextSize)
|
||||
|
||||
|
||||
def SetTextSize(self):
|
||||
self.txt.SetSize(self.txt.GetBestSize())
|
||||
|
||||
|
||||
def OnSelect(self, evt):
|
||||
#print "OnSelect: "
|
||||
face = self.lb1.GetStringSelection()
|
||||
#print '\t '+face
|
||||
font = wxFont(28, wxDEFAULT, wxNORMAL, wxNORMAL, False, face)
|
||||
#print "\t got font"
|
||||
self.txt.SetLabel(face)
|
||||
#print "\t set label"
|
||||
self.txt.SetFont(font)
|
||||
self.txt.SetSize(self.txt.GetBestSize())
|
||||
#print "\t set font"
|
||||
#self.txt.SetSize(self.txt.GetBestSize())
|
||||
#print "\t set size"
|
||||
|
||||
|
||||
## st = font.GetNativeFontInfo().ToString()
|
||||
## ni2 = wxNativeFontInfo()
|
||||
|
104
wxPython/demo/GridDragAndDrop.py
Normal file
104
wxPython/demo/GridDragAndDrop.py
Normal file
@@ -0,0 +1,104 @@
|
||||
"""
|
||||
Example showing how to make a grid a drop target for files.
|
||||
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.grid import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Set VIRTUAL to 1 to use a virtual grid
|
||||
|
||||
VIRTUAL = 1
|
||||
|
||||
class GridFileDropTarget(wxFileDropTarget):
|
||||
def __init__(self, grid):
|
||||
wxFileDropTarget.__init__(self)
|
||||
self.grid = grid
|
||||
|
||||
def OnDropFiles(self, x, y, filenames):
|
||||
# the x,y coordinates here are Unscrolled coordinates. They must be changed
|
||||
# to scrolled coordinates.
|
||||
x, y = self.grid.CalcUnscrolledPosition(x, y)
|
||||
|
||||
# now we need to get the row and column from the grid
|
||||
# but we need to first remove the RowLabel and ColumnLabel
|
||||
# bounding boxes
|
||||
# Why this isn't done for us, I'll never know...
|
||||
x = x - self.grid.GetGridRowLabelWindow().GetRect().width
|
||||
y = y - self.grid.GetGridColLabelWindow().GetRect().height
|
||||
col = self.grid.XToCol(x)
|
||||
row = self.grid.YToRow(y)
|
||||
|
||||
if row > -1 and col > -1:
|
||||
self.grid.SetCellValue(row, col, filenames[0])
|
||||
self.grid.AutoSizeColumn(col)
|
||||
self.grid.Refresh()
|
||||
|
||||
|
||||
|
||||
class FooTable(wxPyGridTableBase):
|
||||
def __init__(self):
|
||||
wxPyGridTableBase.__init__(self)
|
||||
self.dropTargets = {(0,0):"Drag",
|
||||
(1,0):"A",
|
||||
(2,0):"File",
|
||||
(3,0):"To",
|
||||
(4,0):"A",
|
||||
(5,0):"Cell"}
|
||||
def GetNumberCols(self):
|
||||
return 100
|
||||
def GetNumberRows(self):
|
||||
return 100
|
||||
def GetValue(self, row, col):
|
||||
return self.dropTargets.get((row, col), "")
|
||||
|
||||
|
||||
|
||||
class SimpleGrid(wxGrid):
|
||||
def __init__(self, parent, log):
|
||||
wxGrid.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.moveTo = None
|
||||
if VIRTUAL:
|
||||
self.table = FooTable()
|
||||
self.SetTable(self.table)
|
||||
else:
|
||||
self.CreateGrid(25, 25)
|
||||
|
||||
# set the drag and drop target
|
||||
dropTarget = GridFileDropTarget(self)
|
||||
self.SetDropTarget(dropTarget)
|
||||
self.EnableDragRowSize()
|
||||
self.EnableDragColSize()
|
||||
|
||||
def SetCellValue(self, row, col, value):
|
||||
if VIRTUAL:
|
||||
self.table.dropTargets[row, col] = value
|
||||
else:
|
||||
wxGrid.SetCellValue(self, row, col, value)
|
||||
|
||||
|
||||
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, "DragAndDrop Grid", size=(640,480))
|
||||
grid = SimpleGrid(self, log)
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
app = wxPySimpleApp()
|
||||
frame = TestFrame(None, sys.stdout)
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
@@ -64,6 +64,11 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin):
|
||||
self.SetCellValue(11, 1, "This cell is set to span 3 rows and 3 columns");
|
||||
|
||||
|
||||
editor = wxGridCellTextEditor()
|
||||
editor.SetParameters('10')
|
||||
self.SetCellEditor(0, 4, editor)
|
||||
self.SetCellValue(0, 4, "Limited text")
|
||||
|
||||
|
||||
# test all the events
|
||||
EVT_GRID_CELL_LEFT_CLICK(self, self.OnCellLeftClick)
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
||||
#
|
||||
# Version 0.5
|
||||
# Version 0.5
|
||||
# Date: Feb 26, 2001
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
@@ -20,11 +20,11 @@ def runTest(frame, nb, log):
|
||||
initial_dir = os.path.join(dir, 'bitmaps') # set the initial directory for the demo bitmaps
|
||||
win = ImageDialog(frame, initial_dir) # open the image browser dialog
|
||||
win.Centre()
|
||||
if win.ShowModal() == wxID_OK:
|
||||
if win.ShowModal() == wxID_OK:
|
||||
log.WriteText("You Selected File: " + win.GetFile()) # show the selected file
|
||||
else:
|
||||
log.WriteText("You pressed Cancel\n")
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -38,3 +38,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -136,5 +136,8 @@ overview = """<html><body>
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -60,3 +60,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
overview = Layoutf.__doc__
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -12,10 +12,9 @@
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
import sys, os, time
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import wxHtmlWindow
|
||||
|
||||
##from wxPython.stc import *
|
||||
import wx # This module uses the new wx namespace
|
||||
import wx.html
|
||||
|
||||
import images
|
||||
|
||||
@@ -26,9 +25,14 @@ import images
|
||||
_treeList = [
|
||||
# new stuff
|
||||
('Recent Additions', [
|
||||
'wxIntCtrl',
|
||||
'wxPyColourChooser',
|
||||
'wxScrolledPanel',
|
||||
'ShapedWindow',
|
||||
'NewNamespace',
|
||||
'PopupMenu',
|
||||
'AnalogClockWindow',
|
||||
'MaskedEditControls',
|
||||
'wxTreeListCtrl',
|
||||
'wxGrid_MegaExample',
|
||||
]),
|
||||
|
||||
# managed windows == things with a (optional) caption you can close
|
||||
@@ -45,6 +49,7 @@ _treeList = [
|
||||
'wxColourDialog',
|
||||
'wxDirDialog',
|
||||
'wxFileDialog',
|
||||
'wxFileDialog_Save',
|
||||
'wxFindReplaceDialog',
|
||||
'wxFontDialog',
|
||||
'wxMessageDialog',
|
||||
@@ -65,6 +70,7 @@ _treeList = [
|
||||
|
||||
# core controls
|
||||
('Core Windows/Controls', [
|
||||
'PopupMenu',
|
||||
'wxButton',
|
||||
'wxCheckBox',
|
||||
'wxCheckListBox',
|
||||
@@ -73,6 +79,7 @@ _treeList = [
|
||||
'wxGauge',
|
||||
'wxGenericDirCtrl',
|
||||
'wxGrid',
|
||||
'wxGrid_MegaExample',
|
||||
'wxListBox',
|
||||
'wxListCtrl',
|
||||
'wxListCtrl_virtual',
|
||||
@@ -101,14 +108,16 @@ _treeList = [
|
||||
('More Windows/Controls', [
|
||||
#'wxFloatBar', deprecated
|
||||
#'wxMVCTree', deprecated
|
||||
#'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now.
|
||||
#'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now.
|
||||
'AnalogClockWindow',
|
||||
'ColourSelect',
|
||||
'ContextHelp',
|
||||
'FancyText',
|
||||
'FileBrowseButton',
|
||||
'GenericButtons',
|
||||
'MaskedEditControls',
|
||||
'PyShell',
|
||||
'PyCrust',
|
||||
'PyCrustWithFilling',
|
||||
'SplitTree',
|
||||
'TablePrint',
|
||||
'Throbber',
|
||||
@@ -128,6 +137,7 @@ _treeList = [
|
||||
'wxStyledTextCtrl_1',
|
||||
'wxStyledTextCtrl_2',
|
||||
'wxTimeCtrl',
|
||||
'wxTreeListCtrl',
|
||||
]),
|
||||
|
||||
# How to lay out the controls in a frame/dialog
|
||||
@@ -204,9 +214,9 @@ _treeList = [
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyLog(wxPyLog):
|
||||
class MyLog(wx.PyLog):
|
||||
def __init__(self, textCtrl, logTime=0):
|
||||
wxPyLog.__init__(self)
|
||||
wx.PyLog.__init__(self)
|
||||
self.tc = textCtrl
|
||||
self.logTime = logTime
|
||||
|
||||
@@ -218,10 +228,63 @@ class MyLog(wxPyLog):
|
||||
self.tc.AppendText(message + '\n')
|
||||
|
||||
|
||||
class MyTP(wxPyTipProvider):
|
||||
class MyTP(wx.PyTipProvider):
|
||||
def GetTip(self):
|
||||
return "This is my tip"
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# A class to be used to display source code in the demo. Try using the
|
||||
# wxSTC in the wxStyledTextCtrl_2 sample first, fall back to wxTextCtrl
|
||||
# if there is an error, such as the stc module not being present.
|
||||
|
||||
try:
|
||||
##raise ImportError
|
||||
from wx import stc
|
||||
from wxStyledTextCtrl_2 import PythonSTC
|
||||
class DemoCodeViewer(PythonSTC):
|
||||
def __init__(self, parent, ID):
|
||||
PythonSTC.__init__(self, parent, ID)
|
||||
self.SetEdgeMode(stc.STC_EDGE_NONE)
|
||||
self.SetSelBackground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT))
|
||||
self.SetSelForeground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))
|
||||
|
||||
# Some methods to make it compatible with how the wxTextCtrl is used
|
||||
def SetValue(self, value):
|
||||
self.SetReadOnly(False)
|
||||
self.SetText(value)
|
||||
self.SetReadOnly(True)
|
||||
|
||||
def Clear(self):
|
||||
self.ClearAll()
|
||||
|
||||
def SetInsertionPoint(self, pos):
|
||||
self.SetCurrentPos(pos)
|
||||
|
||||
def ShowPosition(self, pos):
|
||||
self.GotoPos(pos)
|
||||
|
||||
def GetLastPosition(self):
|
||||
return self.GetLength()
|
||||
|
||||
def GetRange(self, start, end):
|
||||
return self.GetTextRange(start, end)
|
||||
|
||||
def GetSelection(self):
|
||||
return self.GetAnchor(), self.GetCurrentPos()
|
||||
|
||||
def SetSelection(self, start, end):
|
||||
self.SetSelectionStart(start)
|
||||
self.SetSelectionEnd(end)
|
||||
|
||||
|
||||
except ImportError:
|
||||
class DemoCodeViewer(wx.TextCtrl):
|
||||
def __init__(self, parent, ID):
|
||||
wx.TextCtrl.__init__(self, parent, ID, style =
|
||||
wx.TE_MULTILINE | wx.TE_READONLY |
|
||||
wx.HSCROLL | wx.TE_RICH2 | wx.TE_NOHIDESEL)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def opj(path):
|
||||
@@ -231,12 +294,12 @@ def opj(path):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class wxPythonDemo(wxFrame):
|
||||
class wxPythonDemo(wx.Frame):
|
||||
overviewText = "wxPython Overview"
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, -1, title, size = (800, 600),
|
||||
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
wx.Frame.__init__(self, parent, -1, title, size = (800, 600),
|
||||
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
|
||||
|
||||
self.cwd = os.getcwd()
|
||||
self.curOverview = ""
|
||||
@@ -245,97 +308,97 @@ class wxPythonDemo(wxFrame):
|
||||
icon = images.getMondrianIcon()
|
||||
self.SetIcon(icon)
|
||||
|
||||
if wxPlatform == '__WXMSW__':
|
||||
if wx.Platform == '__WXMSW__':
|
||||
# setup a taskbar icon, and catch some events from it
|
||||
self.tbicon = wxTaskBarIcon()
|
||||
self.tbicon = wx.TaskBarIcon()
|
||||
self.tbicon.SetIcon(icon, "wxPython Demo")
|
||||
EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate)
|
||||
EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarMenu)
|
||||
EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
|
||||
EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
|
||||
wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate)
|
||||
wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarMenu)
|
||||
wx.EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
|
||||
wx.EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
|
||||
|
||||
wxCallAfter(self.ShowTip)
|
||||
wx.CallAfter(self.ShowTip)
|
||||
|
||||
self.otherWin = None
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
EVT_ICONIZE(self, self.OnIconfiy)
|
||||
EVT_MAXIMIZE(self, self.OnMaximize)
|
||||
wx.EVT_IDLE(self, self.OnIdle)
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
wx.EVT_ICONIZE(self, self.OnIconfiy)
|
||||
wx.EVT_MAXIMIZE(self, self.OnMaximize)
|
||||
|
||||
self.Centre(wxBOTH)
|
||||
self.CreateStatusBar(1, wxST_SIZEGRIP)
|
||||
self.Centre(wx.BOTH)
|
||||
self.CreateStatusBar(1, wx.ST_SIZEGRIP)
|
||||
|
||||
splitter = wxSplitterWindow(self, -1, style=wxNO_3D|wxSP_3D)
|
||||
splitter2 = wxSplitterWindow(splitter, -1, style=wxNO_3D|wxSP_3D)
|
||||
splitter = wx.SplitterWindow(self, -1, style=wx.NO_3D|wx.SP_3D)
|
||||
splitter2 = wx.SplitterWindow(splitter, -1, style=wx.NO_3D|wx.SP_3D)
|
||||
|
||||
def EmptyHandler(evt): pass
|
||||
EVT_ERASE_BACKGROUND(splitter, EmptyHandler)
|
||||
EVT_ERASE_BACKGROUND(splitter2, EmptyHandler)
|
||||
wx.EVT_ERASE_BACKGROUND(splitter, EmptyHandler)
|
||||
wx.EVT_ERASE_BACKGROUND(splitter2, EmptyHandler)
|
||||
|
||||
# Prevent TreeCtrl from displaying all items after destruction when True
|
||||
self.dying = False
|
||||
|
||||
# Make a File menu
|
||||
self.mainmenu = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
exitID = wxNewId()
|
||||
self.mainmenu = wx.MenuBar()
|
||||
menu = wx.Menu()
|
||||
exitID = wx.NewId()
|
||||
menu.Append(exitID, 'E&xit\tAlt-X', 'Get the heck outta here!')
|
||||
EVT_MENU(self, exitID, self.OnFileExit)
|
||||
wxApp_SetMacExitMenuItemId(exitID)
|
||||
wx.EVT_MENU(self, exitID, self.OnFileExit)
|
||||
wx.App_SetMacExitMenuItemId(exitID)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
# Make a Demo menu
|
||||
menu = wxMenu()
|
||||
menu = wx.Menu()
|
||||
for item in _treeList:
|
||||
submenu = wxMenu()
|
||||
submenu = wx.Menu()
|
||||
for childItem in item[1]:
|
||||
mID = wxNewId()
|
||||
mID = wx.NewId()
|
||||
submenu.Append(mID, childItem)
|
||||
EVT_MENU(self, mID, self.OnDemoMenu)
|
||||
menu.AppendMenu(wxNewId(), item[0], submenu)
|
||||
wx.EVT_MENU(self, mID, self.OnDemoMenu)
|
||||
menu.AppendMenu(wx.NewId(), item[0], submenu)
|
||||
self.mainmenu.Append(menu, '&Demo')
|
||||
|
||||
|
||||
# Make a Help menu
|
||||
helpID = wxNewId()
|
||||
findID = wxNewId()
|
||||
findnextID = wxNewId()
|
||||
menu = wxMenu()
|
||||
helpID = wx.NewId()
|
||||
findID = wx.NewId()
|
||||
findnextID = wx.NewId()
|
||||
menu = wx.Menu()
|
||||
menu.Append(findID, '&Find\tCtrl-F', 'Find in the Demo Code')
|
||||
menu.Append(findnextID, 'Find &Next\tF3', 'Find Next')
|
||||
menu.AppendSeparator()
|
||||
menu.Append(helpID, '&About\tCtrl-H', 'wxPython RULES!!!')
|
||||
wxApp_SetMacAboutMenuItemId(helpID)
|
||||
EVT_MENU(self, helpID, self.OnHelpAbout)
|
||||
EVT_MENU(self, findID, self.OnHelpFind)
|
||||
EVT_MENU(self, findnextID, self.OnFindNext)
|
||||
EVT_COMMAND_FIND(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_CLOSE(self, -1 , self.OnFindClose)
|
||||
wx.App_SetMacAboutMenuItemId(helpID)
|
||||
wx.EVT_MENU(self, helpID, self.OnHelpAbout)
|
||||
wx.EVT_MENU(self, findID, self.OnHelpFind)
|
||||
wx.EVT_MENU(self, findnextID, self.OnFindNext)
|
||||
wx.EVT_COMMAND_FIND(self, -1, self.OnFind)
|
||||
wx.EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind)
|
||||
wx.EVT_COMMAND_FIND_CLOSE(self, -1 , self.OnFindClose)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
self.finddata = wxFindReplaceData()
|
||||
self.finddata = wx.FindReplaceData()
|
||||
|
||||
if 0:
|
||||
# This is another way to set Accelerators, in addition to
|
||||
# using the '\t<key>' syntax in the menu items.
|
||||
aTable = wxAcceleratorTable([(wxACCEL_ALT, ord('X'), exitID),
|
||||
(wxACCEL_CTRL, ord('H'), helpID),
|
||||
(wxACCEL_CTRL, ord('F'), findID),
|
||||
(wxACCEL_NORMAL, WXK_F3, findnextID)])
|
||||
aTable = wx.AcceleratorTable([(wx.ACCEL_ALT, ord('X'), exitID),
|
||||
(wx.ACCEL_CTRL, ord('H'), helpID),
|
||||
(wx.ACCEL_CTRL, ord('F'), findID),
|
||||
(wx.ACCEL_NORMAL, WXK_F3, findnextID)
|
||||
])
|
||||
self.SetAcceleratorTable(aTable)
|
||||
|
||||
|
||||
# Create a TreeCtrl
|
||||
tID = wxNewId()
|
||||
tID = wx.NewId()
|
||||
self.treeMap = {}
|
||||
self.tree = wxTreeCtrl(splitter, tID,
|
||||
style=wxTR_HAS_BUTTONS |
|
||||
wxTR_HAS_VARIABLE_ROW_HEIGHT
|
||||
self.tree = wx.TreeCtrl(splitter, tID,
|
||||
style=wx.TR_HAS_BUTTONS |
|
||||
wx.TR_HAS_VARIABLE_ROW_HEIGHT
|
||||
)
|
||||
|
||||
#self.tree.SetBackgroundColour(wxNamedColour("Pink"))
|
||||
root = self.tree.AddRoot("wxPython Overview")
|
||||
firstChild = None
|
||||
for item in _treeList:
|
||||
@@ -347,57 +410,56 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
self.tree.Expand(root)
|
||||
self.tree.Expand(firstChild)
|
||||
EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded)
|
||||
EVT_TREE_ITEM_COLLAPSED (self.tree, tID, self.OnItemCollapsed)
|
||||
EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged)
|
||||
EVT_LEFT_DOWN (self.tree, self.OnTreeLeftDown)
|
||||
wx.EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded)
|
||||
wx.EVT_TREE_ITEM_COLLAPSED (self.tree, tID, self.OnItemCollapsed)
|
||||
wx.EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged)
|
||||
wx.EVT_LEFT_DOWN (self.tree, self.OnTreeLeftDown)
|
||||
|
||||
# Create a Notebook
|
||||
self.nb = wxNotebook(splitter2, -1, style=wxCLIP_CHILDREN)
|
||||
self.nb = wx.Notebook(splitter2, -1, style=wx.CLIP_CHILDREN)
|
||||
|
||||
# Set up a wxHtmlWindow on the Overview Notebook page
|
||||
# Set up a wx.html.HtmlWindow on the Overview Notebook page
|
||||
# we put it in a panel first because there seems to be a
|
||||
# refresh bug of some sort (wxGTK) when it is directly in
|
||||
# the notebook...
|
||||
if 0: # the old way
|
||||
self.ovr = wxHtmlWindow(self.nb, -1, size=(400, 400))
|
||||
self.ovr = wx.html.HtmlWindow(self.nb, -1, size=(400, 400))
|
||||
self.nb.AddPage(self.ovr, self.overviewText)
|
||||
|
||||
else: # hopefully I can remove this hacky code soon, see bug #216861
|
||||
panel = wxPanel(self.nb, -1, style=wxCLIP_CHILDREN)
|
||||
self.ovr = wxHtmlWindow(panel, -1, size=(400, 400))
|
||||
else: # hopefully I can remove this hacky code soon, see SF bug #216861
|
||||
panel = wx.Panel(self.nb, -1, style=wx.CLIP_CHILDREN)
|
||||
self.ovr = wx.html.HtmlWindow(panel, -1, size=(400, 400))
|
||||
self.nb.AddPage(panel, self.overviewText)
|
||||
|
||||
def OnOvrSize(evt, ovr=self.ovr):
|
||||
ovr.SetSize(evt.GetSize())
|
||||
|
||||
EVT_SIZE(panel, OnOvrSize)
|
||||
EVT_ERASE_BACKGROUND(panel, EmptyHandler)
|
||||
wx.EVT_SIZE(panel, OnOvrSize)
|
||||
wx.EVT_ERASE_BACKGROUND(panel, EmptyHandler)
|
||||
|
||||
|
||||
self.SetOverview(self.overviewText, overview)
|
||||
|
||||
|
||||
# Set up a TextCtrl on the Demo Code Notebook page
|
||||
self.txt = wxTextCtrl(self.nb, -1,
|
||||
style = wxTE_MULTILINE|wxTE_READONLY|
|
||||
wxHSCROLL|wxTE_RICH2|wxTE_NOHIDESEL)
|
||||
# Set up a notebook page for viewing the source code of each sample
|
||||
self.txt = DemoCodeViewer(self.nb, -1)
|
||||
self.nb.AddPage(self.txt, "Demo Code")
|
||||
self.GetDemoFile('Main.py')
|
||||
|
||||
|
||||
# Set up a log on the View Log Notebook page
|
||||
self.log = wxTextCtrl(splitter2, -1,
|
||||
style = wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
|
||||
self.log = wx.TextCtrl(splitter2, -1,
|
||||
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
|
||||
|
||||
# Set the wxWindows log target to be this textctrl
|
||||
#wxLog_SetActiveTarget(wxLogTextCtrl(self.log))
|
||||
#wx.Log_SetActiveTarget(wx.LogTextCtrl(self.log))
|
||||
|
||||
# But instead of the above we want to show how to use our own wxLog class
|
||||
wxLog_SetActiveTarget(MyLog(self.log))
|
||||
# But instead of the above we want to show how to use our own wx.Log class
|
||||
wx.Log_SetActiveTarget(MyLog(self.log))
|
||||
|
||||
# for serious debugging
|
||||
#wxLog_SetActiveTarget(wxLogStderr())
|
||||
#wxLog_SetTraceMask(wxTraceMessages)
|
||||
#wx.Log_SetActiveTarget(wx.LogStderr())
|
||||
#wx.Log_SetTraceMask(wx.TraceMessages)
|
||||
|
||||
self.Show(True)
|
||||
|
||||
@@ -425,14 +487,14 @@ class wxPythonDemo(wxFrame):
|
||||
self.tree.EnsureVisible(selectedDemo)
|
||||
|
||||
|
||||
wxLogMessage('window handle: %s' % self.GetHandle())
|
||||
wx.LogMessage('window handle: %s' % self.GetHandle())
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def WriteText(self, text):
|
||||
if text[-1:] == '\n':
|
||||
text = text[:-1]
|
||||
wxLogMessage(text)
|
||||
wx.LogMessage(text)
|
||||
|
||||
|
||||
def write(self, txt):
|
||||
@@ -441,13 +503,13 @@ class wxPythonDemo(wxFrame):
|
||||
#---------------------------------------------
|
||||
def OnItemExpanded(self, event):
|
||||
item = event.GetItem()
|
||||
wxLogMessage("OnItemExpanded: %s" % self.tree.GetItemText(item))
|
||||
wx.LogMessage("OnItemExpanded: %s" % self.tree.GetItemText(item))
|
||||
event.Skip()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnItemCollapsed(self, event):
|
||||
item = event.GetItem()
|
||||
wxLogMessage("OnItemCollapsed: %s" % self.tree.GetItemText(item))
|
||||
wx.LogMessage("OnItemCollapsed: %s" % self.tree.GetItemText(item))
|
||||
event.Skip()
|
||||
|
||||
#---------------------------------------------
|
||||
@@ -478,7 +540,7 @@ class wxPythonDemo(wxFrame):
|
||||
if self.window is not None:
|
||||
if hasattr(self.window, "ShutdownDemo"):
|
||||
self.window.ShutdownDemo()
|
||||
wxSafeYield() # in case the page has pending events
|
||||
wx.SafeYield() # in case the page has pending events
|
||||
self.nb.DeletePage(2)
|
||||
|
||||
if itemText == self.overviewText:
|
||||
@@ -489,19 +551,19 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
else:
|
||||
if os.path.exists(itemText + '.py'):
|
||||
wxBeginBusyCursor()
|
||||
wxLogMessage("Running demo %s.py..." % itemText)
|
||||
wx.BeginBusyCursor()
|
||||
wx.LogMessage("Running demo %s.py..." % itemText)
|
||||
try:
|
||||
self.GetDemoFile(itemText + '.py')
|
||||
module = __import__(itemText, globals())
|
||||
self.SetOverview(itemText + " Overview", module.overview)
|
||||
finally:
|
||||
wxEndBusyCursor()
|
||||
wx.EndBusyCursor()
|
||||
self.tree.Refresh()
|
||||
|
||||
# in case runTest is modal, make sure things look right...
|
||||
self.nb.Refresh();
|
||||
wxSafeYield()
|
||||
wx.SafeYield()
|
||||
|
||||
self.window = module.runTest(self, self.nb, self) ###
|
||||
if self.window is not None:
|
||||
@@ -523,7 +585,7 @@ class wxPythonDemo(wxFrame):
|
||||
try:
|
||||
self.txt.SetValue(open(filename).read())
|
||||
except IOError:
|
||||
self.txt.WriteText("Cannot open %s file." % filename)
|
||||
self.txt.SetValue("Cannot open %s file." % filename)
|
||||
|
||||
self.txt.SetInsertionPoint(0)
|
||||
self.txt.ShowPosition(0)
|
||||
@@ -550,10 +612,10 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
def OnHelpFind(self, event):
|
||||
self.nb.SetSelection(1)
|
||||
self.finddlg = wxFindReplaceDialog(self, self.finddata, "Find",
|
||||
wxFR_NOUPDOWN |
|
||||
wxFR_NOMATCHCASE |
|
||||
wxFR_NOWHOLEWORD)
|
||||
self.finddlg = wx.FindReplaceDialog(self, self.finddata, "Find",
|
||||
wx.FR_NOUPDOWN |
|
||||
wx.FR_NOMATCHCASE |
|
||||
wx.FR_NOWHOLEWORD)
|
||||
self.finddlg.Show(True)
|
||||
|
||||
def OnFind(self, event):
|
||||
@@ -568,9 +630,9 @@ class wxPythonDemo(wxFrame):
|
||||
start = 0
|
||||
loc = textstring.find(findstring, start)
|
||||
if loc == -1:
|
||||
dlg = wxMessageDialog(self, 'Find String Not Found',
|
||||
dlg = wx.MessageDialog(self, 'Find String Not Found',
|
||||
'Find String Not Found in Demo File',
|
||||
wxOK | wxICON_INFORMATION)
|
||||
wx.OK | wx.ICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
if self.finddlg:
|
||||
@@ -579,8 +641,8 @@ class wxPythonDemo(wxFrame):
|
||||
return
|
||||
else:
|
||||
self.finddlg.Destroy()
|
||||
self.txt.SetSelection(loc, loc + len(findstring))
|
||||
self.txt.ShowPosition(loc)
|
||||
self.txt.SetSelection(loc, loc + len(findstring))
|
||||
|
||||
|
||||
|
||||
@@ -620,9 +682,9 @@ class wxPythonDemo(wxFrame):
|
||||
except IOError:
|
||||
showTip, index = (1, 0)
|
||||
if showTip:
|
||||
tp = wxCreateFileTipProvider(opj("data/tips.txt"), index)
|
||||
tp = wx.CreateFileTipProvider(opj("data/tips.txt"), index)
|
||||
##tp = MyTP(0)
|
||||
showTip = wxShowTip(self, tp)
|
||||
showTip = wx.ShowTip(self, tp)
|
||||
index = tp.GetCurrentTip()
|
||||
open(opj("data/showTips"), "w").write(str( (showTip, index) ))
|
||||
|
||||
@@ -652,7 +714,7 @@ class wxPythonDemo(wxFrame):
|
||||
TBMENU_CLOSE = 1001
|
||||
|
||||
def OnTaskBarMenu(self, evt):
|
||||
menu = wxMenu()
|
||||
menu = wx.Menu()
|
||||
menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo")
|
||||
menu.Append(self.TBMENU_CLOSE, "Close")
|
||||
self.tbicon.PopupMenu(menu)
|
||||
@@ -662,19 +724,19 @@ class wxPythonDemo(wxFrame):
|
||||
def OnTaskBarClose(self, evt):
|
||||
self.Close()
|
||||
|
||||
# because of the way wxTaskBarIcon.PopupMenu is implemented we have to
|
||||
# because of the way wx.TaskBarIcon.PopupMenu is implemented we have to
|
||||
# prod the main idle handler a bit to get the window to actually close
|
||||
wxGetApp().ProcessIdle()
|
||||
wx.GetApp().ProcessIdle()
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def OnIconfiy(self, evt):
|
||||
wxLogMessage("OnIconfiy")
|
||||
wx.LogMessage("OnIconfiy")
|
||||
evt.Skip()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnMaximize(self, evt):
|
||||
wxLogMessage("OnMaximize")
|
||||
wx.LogMessage("OnMaximize")
|
||||
evt.Skip()
|
||||
|
||||
|
||||
@@ -683,14 +745,14 @@ class wxPythonDemo(wxFrame):
|
||||
#---------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MySplashScreen(wxSplashScreen):
|
||||
class MySplashScreen(wx.SplashScreen):
|
||||
def __init__(self):
|
||||
bmp = wxImage(opj("bitmaps/splash.gif")).ConvertToBitmap()
|
||||
wxSplashScreen.__init__(self, bmp,
|
||||
wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
|
||||
bmp = wx.Image(opj("bitmaps/splash.gif")).ConvertToBitmap()
|
||||
wx.SplashScreen.__init__(self, bmp,
|
||||
wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,
|
||||
4000, None, -1,
|
||||
style = wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP)
|
||||
EVT_CLOSE(self, self.OnClose)
|
||||
style = wx.SIMPLE_BORDER|wx.FRAME_NO_TASKBAR|wx.STAY_ON_TOP)
|
||||
wx.EVT_CLOSE(self, self.OnClose)
|
||||
|
||||
def OnClose(self, evt):
|
||||
frame = wxPythonDemo(None, -1, "wxPython: (A Demonstration)")
|
||||
@@ -698,7 +760,7 @@ class MySplashScreen(wxSplashScreen):
|
||||
evt.Skip() # Make sure the default handler runs too...
|
||||
|
||||
|
||||
class MyApp(wxApp):
|
||||
class MyApp(wx.App):
|
||||
def OnInit(self):
|
||||
"""
|
||||
Create and show the splash screen. It will then create and show
|
||||
@@ -706,10 +768,10 @@ class MyApp(wxApp):
|
||||
"""
|
||||
|
||||
#import locale
|
||||
#self.locale = wxLocale(wxLANGUAGE_FRENCH)
|
||||
#self.locale = wx.Locale(wx.LANGUAGE_FRENCH)
|
||||
#locale.setlocale(locale.LC_ALL, 'fr')
|
||||
|
||||
wxInitAllImageHandlers()
|
||||
wx.InitAllImageHandlers()
|
||||
splash = MySplashScreen()
|
||||
splash.Show()
|
||||
return True
|
||||
@@ -724,7 +786,7 @@ def main():
|
||||
os.chdir(demoPath)
|
||||
except:
|
||||
pass
|
||||
app = MyApp(wxPlatform == "__WXMAC__")
|
||||
app = MyApp(wx.Platform == "__WXMAC__")
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
@@ -733,76 +795,36 @@ def main():
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2>Python</h2>
|
||||
<h2>wxPython</h2>
|
||||
|
||||
Python is an interpreted, interactive, object-oriented programming
|
||||
language often compared to Tcl, Perl, Scheme, or Java.
|
||||
<p> wxPython is a <b>GUI toolkit</b> for the <a
|
||||
href="http://www.python.org/">Python</a> programming language. It
|
||||
allows Python programmers to create programs with a robust, highly
|
||||
functional graphical user interface, simply and easily. It is
|
||||
implemented as a Python extension module (native code) that wraps the
|
||||
popular <a href="http://wxwindows.org/front.htm">wxWindows</a> cross
|
||||
platform GUI library, which is written in C++.
|
||||
|
||||
<p> Python combines remarkable power with very clear syntax. It has
|
||||
modules, classes, exceptions, very high level dynamic data types, and
|
||||
dynamic typing. There are interfaces to many system calls and
|
||||
libraries, and new built-in modules are easily written in C or
|
||||
C++. Python is also usable as an extension language for applications
|
||||
that need a programmable interface. <p>
|
||||
<p> Like Python and wxWindows, wxPython is <b>Open Source</b> which
|
||||
means that it is free for anyone to use and the source code is
|
||||
available for anyone to look at and modify. Or anyone can contribute
|
||||
fixes or enhnacments to the project.
|
||||
|
||||
<h2>wxWindows</h2>
|
||||
<p> wxPython is a <b>cross-platform</b> toolkit. This means that the
|
||||
same program will run on multiple platforms without modification.
|
||||
Currently supported platforms are 32-bit Microsoft Windows, most Unix
|
||||
or unix-like systems, and Macintosh OS X. Since the language is
|
||||
Python, wxPython programs are <b>simple, easy</b> to write and easy to
|
||||
understand.
|
||||
|
||||
wxWindows is a free C++ framework designed to make cross-platform
|
||||
programming child's play. Well, almost. wxWindows 2 supports Windows
|
||||
3.1/95/98/NT, Unix with GTK/Motif/Lesstif, with a Mac version
|
||||
underway. Other ports are under consideration. <p>
|
||||
<p> <b>This demo</b> is not only a collection of test cases for
|
||||
wxPython, but is also designed to help you learn about and how to use
|
||||
wxPython. Each sample is listed in the tree control on the left.
|
||||
When a sample is selected in the tree then a module is loaded and run
|
||||
(usually in a tab of this notebook,) and the source code of the module
|
||||
is loaded in another tab for you to browse and learn from.
|
||||
|
||||
wxWindows is a set of libraries that allows C++ applications to
|
||||
compile and run on several different types of computers, with minimal
|
||||
source code changes. There is one library per supported GUI (such as
|
||||
Motif, or Windows). As well as providing a common API (Application
|
||||
Programming Interface) for GUI functionality, it provides
|
||||
functionality for accessing some commonly-used operating system
|
||||
facilities, such as copying or deleting files. wxWindows is a
|
||||
'framework' in the sense that it provides a lot of built-in
|
||||
functionality, which the application can use or replace as required,
|
||||
thus saving a great deal of coding effort. Basic data structures such
|
||||
as strings, linked lists and hash tables are also supported.
|
||||
|
||||
<p>
|
||||
<h2>wxPython</h2>
|
||||
|
||||
wxPython is a Python extension module that encapsulates the wxWindows
|
||||
GUI classes. Currently it is only available for the Win32 and GTK
|
||||
ports of wxWindows, but as soon as the other ports are brought up to
|
||||
the same level as Win32 and GTK, it should be fairly trivial to
|
||||
enable wxPython to be used with the new GUI.
|
||||
|
||||
<p>
|
||||
|
||||
The wxPython extension module attempts to mirror the class heiarchy
|
||||
of wxWindows as closely as possible. This means that there is a
|
||||
wxFrame class in wxPython that looks, smells, tastes and acts almost
|
||||
the same as the wxFrame class in the C++ version. Unfortunately,
|
||||
because of differences in the languages, wxPython doesn't match
|
||||
wxWindows exactly, but the differences should be easy to absorb
|
||||
because they are natural to Python. For example, some methods that
|
||||
return multiple values via argument pointers in C++ will return a
|
||||
tuple of values in Python.
|
||||
|
||||
<p>
|
||||
|
||||
There is still much to be done for wxPython, many classes still need
|
||||
to be mirrored. Also, wxWindows is still somewhat of a moving target
|
||||
so it is a bit of an effort just keeping wxPython up to date. On the
|
||||
other hand, there are enough of the core classes completed that
|
||||
useful applications can be written.
|
||||
|
||||
<p>
|
||||
|
||||
wxPython is close enough to the C++ version that the majority of
|
||||
the wxPython documentation is actually just notes attached to the C++
|
||||
documents that describe the places where wxPython is different. There
|
||||
is also a series of sample programs included, and a series of
|
||||
documentation pages that assist the programmer in getting started
|
||||
with wxPython.
|
||||
|
||||
"""
|
||||
"""
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
540
wxPython/demo/MaskedEditControls.py
Normal file
540
wxPython/demo/MaskedEditControls.py
Normal file
@@ -0,0 +1,540 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.maskededit import Field, wxMaskedTextCtrl, wxMaskedComboBox, wxIpAddrCtrl, states, months
|
||||
from wxPython.lib.maskededit import __doc__ as overviewdoc
|
||||
from wxPython.lib.maskededit import autoformats
|
||||
from wxPython.lib.scrolledpanel import wxScrolledPanel
|
||||
import string, sys, traceback
|
||||
|
||||
class demoMixin:
|
||||
"""
|
||||
Centralized routines common to demo pages, to remove repetition.
|
||||
"""
|
||||
def labelGeneralTable(self, sizer):
|
||||
description = wxStaticText( self, -1, "Description", )
|
||||
mask = wxStaticText( self, -1, "Mask Value" )
|
||||
formatcode = wxStaticText( self, -1, "Format" )
|
||||
regex = wxStaticText( self, -1, "Regexp Validator(opt.)" )
|
||||
ctrl = wxStaticText( self, -1, "wxMaskedEdit Ctrl" )
|
||||
|
||||
description.SetFont( wxFont(9, wxSWISS, wxNORMAL, wxBOLD))
|
||||
mask.SetFont( wxFont(9, wxSWISS, wxNORMAL, wxBOLD))
|
||||
formatcode.SetFont( wxFont(9, wxSWISS, wxNORMAL, wxBOLD) )
|
||||
regex.SetFont( wxFont(9, wxSWISS, wxNORMAL, wxBOLD))
|
||||
ctrl.SetFont( wxFont(9, wxSWISS, wxNORMAL, wxBOLD))
|
||||
|
||||
sizer.Add(description)
|
||||
sizer.Add(mask)
|
||||
sizer.Add(formatcode)
|
||||
sizer.Add(regex)
|
||||
sizer.Add(ctrl)
|
||||
|
||||
|
||||
def layoutGeneralTable(self, controls, sizer):
|
||||
for control in controls:
|
||||
sizer.Add( wxStaticText( self, -1, control[0]) )
|
||||
sizer.Add( wxStaticText( self, -1, control[1]) )
|
||||
sizer.Add( wxStaticText( self, -1, control[3]) )
|
||||
sizer.Add( wxStaticText( self, -1, control[4]) )
|
||||
|
||||
if control in controls:
|
||||
newControl = wxMaskedTextCtrl( self, -1, "",
|
||||
mask = control[1],
|
||||
excludeChars = control[2],
|
||||
formatcodes = control[3],
|
||||
includeChars = "",
|
||||
validRegex = control[4],
|
||||
validRange = control[5],
|
||||
choices = control[6],
|
||||
choiceRequired = True,
|
||||
defaultValue = control[7],
|
||||
demo = True,
|
||||
name = control[0])
|
||||
self.editList.append(newControl)
|
||||
sizer.Add(newControl)
|
||||
|
||||
|
||||
def changeControlParams(self, event, parameter, checked_value, notchecked_value):
|
||||
if event.Checked(): value = checked_value
|
||||
else: value = notchecked_value
|
||||
kwargs = {parameter: value}
|
||||
for control in self.editList:
|
||||
control.SetCtrlParameters(**kwargs)
|
||||
control.Refresh()
|
||||
self.Refresh()
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
class demoPage1(wxScrolledPanel, demoMixin):
|
||||
def __init__(self, parent, log):
|
||||
wxScrolledPanel.__init__(self, parent, -1)
|
||||
self.sizer = wxBoxSizer( wxVERTICAL )
|
||||
self.editList = []
|
||||
|
||||
label = wxStaticText( self, -1, """\
|
||||
Here are some basic wxMaskedTextCtrls to give you an idea of what you can do
|
||||
with this control. Note that all controls have been auto-sized by including 'F' in
|
||||
the format codes.
|
||||
|
||||
Try entering nonsensical or partial values in validated fields to see what happens.
|
||||
Note that the State and Last Name fields are list-limited (valid last names are:
|
||||
Smith, Jones, Williams). Signs on numbers can be toggled with the minus key.
|
||||
""")
|
||||
label.SetForegroundColour( "Blue" )
|
||||
header = wxBoxSizer( wxHORIZONTAL )
|
||||
header.Add( label, 0, flag=wxALIGN_LEFT|wxALL, border = 5 )
|
||||
|
||||
highlight = wxCheckBox( self, -1, "Highlight Empty" )
|
||||
disallow = wxCheckBox( self, -1, "Disallow Empty" )
|
||||
showFill = wxCheckBox( self, -1, "change fillChar" )
|
||||
|
||||
vbox = wxBoxSizer( wxVERTICAL )
|
||||
vbox.Add( highlight, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
vbox.Add( disallow, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
vbox.Add( showFill, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
header.AddSpacer(15, 0)
|
||||
header.Add(vbox, 0, flag=wxALIGN_LEFT|wxALL, border=5 )
|
||||
|
||||
EVT_CHECKBOX( self, highlight.GetId(), self.onHighlightEmpty )
|
||||
EVT_CHECKBOX( self, disallow.GetId(), self.onDisallowEmpty )
|
||||
EVT_CHECKBOX( self, showFill.GetId(), self.onShowFill )
|
||||
|
||||
grid = wxFlexGridSizer( 0, 5, vgap=10, hgap=10 )
|
||||
self.labelGeneralTable(grid)
|
||||
|
||||
# The following list is of the controls for the demo. Feel free to play around with
|
||||
# the options!
|
||||
controls = [
|
||||
#description mask excl format regexp range,list,initial
|
||||
("Phone No", "(###) ###-#### x:###", "", 'F^-', "^\(\d{3}\) \d{3}-\d{4}", '','',''),
|
||||
("Social Sec#", "###-##-####", "", 'F', "\d{3}-\d{2}-\d{4}", '','',''),
|
||||
("Full Name", "C{14}", "", 'F_', '^[A-Z][a-zA-Z]+ [A-Z][a-zA-Z]+', '','',''),
|
||||
("Last Name Only", "C{14}", "", 'F {list}', '^[A-Z][a-zA-Z]+', '',('Smith','Jones','Williams'),''),
|
||||
("Zip plus 4", "#{5}-#{4}", "", 'F', "\d{5}-(\s{4}|\d{4})", '','',''),
|
||||
("Customer No", "\CAA-###", "", 'F!', "C[A-Z]{2}-\d{3}", '','',''),
|
||||
("Invoice Total", "#{9}.##", "", 'F-_,', "", '','',''),
|
||||
("Integer", "#{9}", "", 'F-_', "", '','',''),
|
||||
]
|
||||
|
||||
self.layoutGeneralTable(controls, grid)
|
||||
self.sizer.Add( header, 0, flag=wxALIGN_LEFT|wxALL, border=5 )
|
||||
self.sizer.Add( grid, 0, flag= wxALIGN_LEFT|wxLEFT, border=5 )
|
||||
self.SetSizer(self.sizer)
|
||||
self.SetupScrolling()
|
||||
self.SetAutoLayout(1)
|
||||
|
||||
|
||||
def onDisallowEmpty( self, event ):
|
||||
""" Set emptyInvalid parameter on/off """
|
||||
self.changeControlParams( event, "emptyInvalid", True, False )
|
||||
|
||||
def onHighlightEmpty( self, event ):
|
||||
""" Highlight empty values"""
|
||||
self.changeControlParams( event, "emptyBackgroundColor", "Blue", "White" )
|
||||
|
||||
def onShowFill( self, event ):
|
||||
""" Set fillChar parameter to '?' or ' ' """
|
||||
self.changeControlParams( event, "fillChar", '?', ' ' )
|
||||
|
||||
|
||||
class demoPage2(wxScrolledPanel, demoMixin):
|
||||
def __init__( self, parent, log ):
|
||||
self.log = log
|
||||
wxScrolledPanel.__init__( self, parent, -1 )
|
||||
self.sizer = wxBoxSizer( wxVERTICAL )
|
||||
|
||||
label = wxStaticText( self, -1, """\
|
||||
All these controls have been created by passing a single parameter, the autoformat code.
|
||||
The class contains an internal dictionary of types and formats (autoformats).
|
||||
Many of these already do complicated validation; To see some examples, try
|
||||
29 Feb 2002 vs. 2004 for the date formats, or email address validation.
|
||||
""")
|
||||
|
||||
label.SetForegroundColour( "Blue" )
|
||||
self.sizer.Add( label, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
|
||||
description = wxStaticText( self, -1, "Description")
|
||||
autofmt = wxStaticText( self, -1, "AutoFormat Code")
|
||||
ctrl = wxStaticText( self, -1, "wxMaskedEdit Control")
|
||||
|
||||
description.SetFont( wxFont( 9, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
autofmt.SetFont( wxFont( 9, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
ctrl.SetFont( wxFont( 9, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
|
||||
grid = wxFlexGridSizer( 0, 3, vgap=10, hgap=5 )
|
||||
grid.Add( description, 0, wxALIGN_LEFT )
|
||||
grid.Add( autofmt, 0, wxALIGN_LEFT )
|
||||
grid.Add( ctrl, 0, wxALIGN_LEFT )
|
||||
|
||||
for autoformat, desc in autoformats:
|
||||
grid.Add( wxStaticText( self, -1, desc), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxStaticText( self, -1, autoformat), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxMaskedTextCtrl( self, -1, "",
|
||||
autoformat = autoformat,
|
||||
demo = True,
|
||||
name = autoformat),
|
||||
0, wxALIGN_LEFT )
|
||||
|
||||
self.sizer.Add( grid, 0, wxALIGN_LEFT|wxALL, border=5 )
|
||||
self.SetSizer( self.sizer )
|
||||
self.SetAutoLayout( 1 )
|
||||
self.SetupScrolling()
|
||||
|
||||
|
||||
class demoPage3(wxScrolledPanel, demoMixin):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxScrolledPanel.__init__(self, parent, -1)
|
||||
self.sizer = wxBoxSizer( wxVERTICAL )
|
||||
self.editList = []
|
||||
|
||||
label = wxStaticText( self, -1, """\
|
||||
Here wxMaskedTextCtrls that have default values. The states
|
||||
control has a list of valid values, and the unsigned integer
|
||||
has a legal range specified.
|
||||
""")
|
||||
label.SetForegroundColour( "Blue" )
|
||||
requireValid = wxCheckBox( self, -1, "Require Valid Value" )
|
||||
EVT_CHECKBOX( self, requireValid.GetId(), self.onRequireValid )
|
||||
|
||||
header = wxBoxSizer( wxHORIZONTAL )
|
||||
header.Add( label, 0, flag=wxALIGN_LEFT|wxALL, border = 5)
|
||||
header.AddSpacer(75, 0)
|
||||
header.Add( requireValid, 0, flag=wxALIGN_LEFT|wxALL, border=10 )
|
||||
|
||||
grid = wxFlexGridSizer( 0, 5, vgap=10, hgap=10 )
|
||||
self.labelGeneralTable( grid )
|
||||
|
||||
controls = [
|
||||
#description mask excl format regexp range,list,initial
|
||||
("U.S. State (2 char)", "AA", "", 'F!_', "[A-Z]{2}", '',states, states[0]),
|
||||
("Integer (signed)", "#{6}", "", 'F-_R', "", '','', '0 '),
|
||||
("Integer (unsigned)\n(1-399)","######", "", 'F_', "", (1,399),'', '1 '),
|
||||
("Float (signed)", "#{6}.#{9}", "", 'F-_R', "", '','', '000000.000000000'),
|
||||
("Date (MDY) + Time", "##/##/#### ##:##:## AM", 'BCDEFGHIJKLMNOQRSTUVWXYZ','DF!',"", '','', wxDateTime_Now().Format("%m/%d/%Y %I:%M:%S %p")),
|
||||
]
|
||||
self.layoutGeneralTable( controls, grid )
|
||||
|
||||
self.sizer.Add( header, 0, flag=wxALIGN_LEFT|wxALL, border=5 )
|
||||
self.sizer.Add( grid, 0, flag=wxALIGN_LEFT|wxALL, border=5 )
|
||||
|
||||
self.SetSizer( self.sizer )
|
||||
self.SetAutoLayout( 1 )
|
||||
self.SetupScrolling()
|
||||
|
||||
def onRequireValid( self, event ):
|
||||
""" Set validRequired parameter on/off """
|
||||
self.changeControlParams( event, "validRequired", True, False )
|
||||
|
||||
|
||||
class demoPage4(wxScrolledPanel, demoMixin):
|
||||
def __init__( self, parent, log ):
|
||||
self.log = log
|
||||
wxScrolledPanel.__init__( self, parent, -1 )
|
||||
self.sizer = wxBoxSizer( wxVERTICAL )
|
||||
|
||||
label = wxStaticText( self, -1, """\
|
||||
These controls have field-specific choice lists and allow autocompletion.
|
||||
|
||||
Down arrow or Page Down in an uncompleted field with an auto-completable field will attempt
|
||||
to auto-complete a field if it has a choice list.
|
||||
Page Down and Shift-Down arrow will also auto-complete, or cycle through the complete list.
|
||||
Page Up and Shift-Up arrow will similarly cycle backwards through the list.
|
||||
""")
|
||||
|
||||
label.SetForegroundColour( "Blue" )
|
||||
self.sizer.Add( label, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
|
||||
description = wxStaticText( self, -1, "Description" )
|
||||
autofmt = wxStaticText( self, -1, "AutoFormat Code" )
|
||||
fields = wxStaticText( self, -1, "Field Objects" )
|
||||
ctrl = wxStaticText( self, -1, "wxMaskedEdit Control" )
|
||||
|
||||
description.SetFont( wxFont( 9, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
autofmt.SetFont( wxFont( 9, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
fields.SetFont( wxFont( 9, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
ctrl.SetFont( wxFont( 9, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
|
||||
grid = wxFlexGridSizer( 0, 4, vgap=10, hgap=10 )
|
||||
grid.Add( description, 0, wxALIGN_LEFT )
|
||||
grid.Add( autofmt, 0, wxALIGN_LEFT )
|
||||
grid.Add( fields, 0, wxALIGN_LEFT )
|
||||
grid.Add( ctrl, 0, wxALIGN_LEFT )
|
||||
|
||||
autoformat = "USPHONEFULLEXT"
|
||||
fieldsDict = {0: Field(choices=["617","781","508","978","413"], choiceRequired=True)}
|
||||
fieldsLabel = """\
|
||||
{0: Field(choices=[
|
||||
"617","781",
|
||||
"508","978","413"],
|
||||
choiceRequired=True)}"""
|
||||
grid.Add( wxStaticText( self, -1, "Restricted Area Code"), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxStaticText( self, -1, autoformat), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxStaticText( self, -1, fieldsLabel), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxMaskedTextCtrl( self, -1, "",
|
||||
autoformat = autoformat,
|
||||
fields = fieldsDict,
|
||||
demo = True,
|
||||
name = autoformat),
|
||||
0, wxALIGN_LEFT )
|
||||
|
||||
autoformat = "EXPDATEMMYY"
|
||||
fieldsDict = {1: Field(choices=["03", "04", "05"], choiceRequired=True)}
|
||||
fieldsLabel = """\
|
||||
{1: Field(choices=[
|
||||
"03", "04", "05"],
|
||||
choiceRequired=True)}"""
|
||||
exp = wxMaskedTextCtrl( self, -1, "",
|
||||
autoformat = autoformat,
|
||||
fields = fieldsDict,
|
||||
demo = True,
|
||||
name = autoformat)
|
||||
|
||||
grid.Add( wxStaticText( self, -1, "Restricted Expiration"), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxStaticText( self, -1, autoformat), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxStaticText( self, -1, fieldsLabel), 0, wxALIGN_LEFT )
|
||||
grid.Add( exp, 0, wxALIGN_LEFT )
|
||||
|
||||
fieldsDict = {0: Field(choices=["02134","02155"], choiceRequired=True),
|
||||
1: Field(choices=["1234", "5678"], choiceRequired=False)}
|
||||
fieldsLabel = """\
|
||||
{0: Field(choices=["02134","02155"],
|
||||
choiceRequired=True),
|
||||
1: Field(choices=["1234", "5678"],
|
||||
choiceRequired=False)}"""
|
||||
autoformat = "USZIPPLUS4"
|
||||
zip = wxMaskedTextCtrl( self, -1, "",
|
||||
autoformat = autoformat,
|
||||
fields = fieldsDict,
|
||||
demo = True,
|
||||
name = autoformat)
|
||||
|
||||
grid.Add( wxStaticText( self, -1, "Restricted Zip + 4"), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxStaticText( self, -1, autoformat), 0, wxALIGN_LEFT )
|
||||
grid.Add( wxStaticText( self, -1, fieldsLabel), 0, wxALIGN_LEFT )
|
||||
grid.Add( zip, 0, wxALIGN_LEFT )
|
||||
|
||||
self.sizer.Add( grid, 0, wxALIGN_LEFT|wxALL, border=5 )
|
||||
self.SetSizer( self.sizer )
|
||||
self.SetAutoLayout(1)
|
||||
self.SetupScrolling()
|
||||
|
||||
|
||||
class demoPage5(wxScrolledPanel, demoMixin):
|
||||
def __init__( self, parent, log ):
|
||||
self.log = log
|
||||
wxScrolledPanel.__init__( self, parent, -1 )
|
||||
self.sizer = wxBoxSizer( wxVERTICAL )
|
||||
label = wxStaticText( self, -1, """\
|
||||
These are examples of wxMaskedComboBox and wxIpAddrCtrl, and more useful
|
||||
configurations of a wxMaskedTextCtrl for integer and floating point input.
|
||||
""")
|
||||
label.SetForegroundColour( "Blue" )
|
||||
self.sizer.Add( label, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
|
||||
numerators = [ str(i) for i in range(1, 4) ]
|
||||
denominators = [ string.ljust(str(i), 2) for i in [2,3,4,5,8,16,32,64] ]
|
||||
fieldsDict = {0: Field(choices=numerators, choiceRequired=False),
|
||||
1: Field(choices=denominators, choiceRequired=True)}
|
||||
choices = []
|
||||
for n in numerators:
|
||||
for d in denominators:
|
||||
if n != d:
|
||||
choices.append( '%s/%s' % (n,d) )
|
||||
|
||||
|
||||
text1 = wxStaticText( self, -1, """\
|
||||
A masked ComboBox for fraction selection.
|
||||
Choices for each side of the fraction can be
|
||||
selected with PageUp/Down:""")
|
||||
|
||||
fraction = wxMaskedComboBox( self, -1, "",
|
||||
choices = choices,
|
||||
choiceRequired = True,
|
||||
mask = "#/##",
|
||||
formatcodes = "F_",
|
||||
validRegex = "^\d\/\d\d?",
|
||||
fields = fieldsDict )
|
||||
|
||||
|
||||
text2 = wxStaticText( self, -1, """
|
||||
A masked ComboBox to validate
|
||||
text from a list of numeric codes:""")
|
||||
|
||||
choices = ["91", "136", "305", "4579"]
|
||||
code = wxMaskedComboBox( self, -1, choices[0],
|
||||
choices = choices,
|
||||
choiceRequired = True,
|
||||
formatcodes = "F_r",
|
||||
mask = "####")
|
||||
|
||||
|
||||
text3 = wxStaticText( self, -1, """\
|
||||
A masked state selector; only "legal" values
|
||||
can be entered:""")
|
||||
|
||||
state = wxMaskedComboBox( self, -1, states[0],
|
||||
choices = states,
|
||||
autoformat="USSTATE")
|
||||
|
||||
text4 = wxStaticText( self, -1, "An empty IP Address entry control:")
|
||||
ip_addr1 = wxIpAddrCtrl( self, -1, style = wxTE_PROCESS_TAB )
|
||||
|
||||
|
||||
text5 = wxStaticText( self, -1, "An IP Address control with a restricted mask:")
|
||||
ip_addr2 = wxIpAddrCtrl( self, -1, mask=" 10. 1.109.###" )
|
||||
|
||||
|
||||
text6 = wxStaticText( self, -1, """\
|
||||
An IP Address control with restricted choices
|
||||
of form: 10. (1|2) . (129..255) . (0..255)""")
|
||||
ip_addr3 = wxIpAddrCtrl( self, -1, mask=" 10. #.###.###")
|
||||
ip_addr3.SetFieldParameters(0, validRegex="1|2" ) # requires entry to match or not allowed
|
||||
|
||||
|
||||
# This allows any value in penultimate field, but colors anything outside of the range invalid:
|
||||
ip_addr3.SetFieldParameters(1, validRange=(129,255), validRequired=False )
|
||||
|
||||
text7 = wxStaticText( self, -1, """\
|
||||
A right-insert integer entry control:""")
|
||||
intctrl = wxMaskedTextCtrl(self, -1, name='intctrl', mask="#{9}", formatcodes = '_-r,F')
|
||||
|
||||
text8 = wxStaticText( self, -1, """\
|
||||
A floating point entry control
|
||||
with right-insert for ordinal:""")
|
||||
self.floatctrl = wxMaskedTextCtrl(self, -1, name='floatctrl', mask="#{9}.#{2}", formatcodes="F,_-R")
|
||||
self.floatctrl.SetFieldParameters(0, formatcodes='r<', validRequired=True) # right-insert, require explicit cursor movement to change fields
|
||||
self.floatctrl.SetFieldParameters(1, defaultValue='00') # don't allow blank fraction
|
||||
|
||||
text9 = wxStaticText( self, -1, """\
|
||||
Use this control to programmatically set
|
||||
the value of the above float control:""")
|
||||
number_combo = wxComboBox(self, -1, choices = [ '', '111', '222.22', '-3', '54321.666666666', '-1353.978',
|
||||
'1234567', '-1234567', '123456789', '-123456789.1',
|
||||
'1234567890.', '-1234567890.1' ])
|
||||
|
||||
grid = wxFlexGridSizer( 0, 2, vgap=10, hgap = 5 )
|
||||
grid.Add( text1, 0, wxALIGN_LEFT )
|
||||
grid.Add( fraction, 0, wxALIGN_LEFT )
|
||||
grid.Add( text2, 0, wxALIGN_LEFT )
|
||||
grid.Add( code, 0, wxALIGN_LEFT )
|
||||
grid.Add( text3, 0, wxALIGN_LEFT )
|
||||
grid.Add( state, 0, wxALIGN_LEFT )
|
||||
grid.Add( text4, 0, wxALIGN_LEFT )
|
||||
grid.Add( ip_addr1, 0, wxALIGN_LEFT )
|
||||
grid.Add( text5, 0, wxALIGN_LEFT )
|
||||
grid.Add( ip_addr2, 0, wxALIGN_LEFT )
|
||||
grid.Add( text6, 0, wxALIGN_LEFT )
|
||||
grid.Add( ip_addr3, 0, wxALIGN_LEFT )
|
||||
grid.Add( text7, 0, wxALIGN_LEFT )
|
||||
grid.Add( intctrl, 0, wxALIGN_LEFT )
|
||||
grid.Add( text8, 0, wxALIGN_LEFT )
|
||||
grid.Add( self.floatctrl, 0, wxALIGN_LEFT )
|
||||
grid.Add( text9, 0, wxALIGN_LEFT )
|
||||
grid.Add( number_combo, 0, wxALIGN_LEFT )
|
||||
|
||||
self.sizer.Add( grid, 0, wxALIGN_LEFT|wxALL, border=5 )
|
||||
self.SetSizer( self.sizer )
|
||||
self.SetAutoLayout(1)
|
||||
self.SetupScrolling()
|
||||
|
||||
EVT_COMBOBOX( self, fraction.GetId(), self.OnComboChange )
|
||||
EVT_COMBOBOX( self, code.GetId(), self.OnComboChange )
|
||||
EVT_COMBOBOX( self, state.GetId(), self.OnComboChange )
|
||||
EVT_TEXT( self, fraction.GetId(), self.OnComboChange )
|
||||
EVT_TEXT( self, code.GetId(), self.OnComboChange )
|
||||
EVT_TEXT( self, state.GetId(), self.OnComboChange )
|
||||
|
||||
EVT_TEXT( self, ip_addr1.GetId(), self.OnIpAddrChange )
|
||||
EVT_TEXT( self, ip_addr2.GetId(), self.OnIpAddrChange )
|
||||
EVT_TEXT( self, ip_addr3.GetId(), self.OnIpAddrChange )
|
||||
EVT_TEXT( self, intctrl.GetId(), self.OnTextChange )
|
||||
EVT_TEXT( self, self.floatctrl.GetId(), self.OnTextChange )
|
||||
EVT_COMBOBOX( self, number_combo.GetId(), self.OnNumberSelect )
|
||||
|
||||
|
||||
def OnComboChange( self, event ):
|
||||
ctl = self.FindWindowById( event.GetId() )
|
||||
if not ctl.IsValid():
|
||||
self.log.write('current value not a valid choice')
|
||||
|
||||
def OnIpAddrChange( self, event ):
|
||||
ip_addr = self.FindWindowById( event.GetId() )
|
||||
if ip_addr.IsValid():
|
||||
self.log.write('new addr = %s\n' % ip_addr.GetAddress() )
|
||||
|
||||
def OnTextChange( self, event ):
|
||||
ctl = self.FindWindowById( event.GetId() )
|
||||
if ctl.IsValid():
|
||||
self.log.write('new value = %s\n' % ctl.GetValue() )
|
||||
|
||||
def OnNumberSelect( self, event ):
|
||||
value = event.GetString()
|
||||
|
||||
# Format choice to fit into format for #{9}.#{2}, with sign position reserved:
|
||||
# (ordinal + fraction == 11 + decimal point + sign == 13)
|
||||
#
|
||||
# Note: since self.floatctrl a right-aligned control, you could also just use
|
||||
# "%.2f", but this wouldn't work properly for a left-aligned control.
|
||||
# (See .SetValue() documentation in Overview.)
|
||||
#
|
||||
if value:
|
||||
floattext = "%13.2f" % float(value)
|
||||
else:
|
||||
floattext = value # clear the value again
|
||||
try:
|
||||
self.floatctrl.SetValue(floattext)
|
||||
except:
|
||||
type, value, tb = sys.exc_info()
|
||||
for line in traceback.format_exception_only(type, value):
|
||||
self.log.write(line)
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
class TestMaskedTextCtrls(wxNotebook):
|
||||
def __init__(self, parent, id, log):
|
||||
wxNotebook.__init__(self, parent, id)
|
||||
self.log = log
|
||||
|
||||
win = demoPage1(self, log)
|
||||
self.AddPage(win, "General examples")
|
||||
|
||||
win = demoPage2(self, log)
|
||||
self.AddPage(win, 'Auto-formatted controls')
|
||||
|
||||
win = demoPage3(self, log)
|
||||
self.AddPage(win, "Using default values")
|
||||
|
||||
win = demoPage4(self, log)
|
||||
self.AddPage(win, 'Using auto-complete fields')
|
||||
|
||||
win = demoPage5(self, log)
|
||||
self.AddPage(win, 'Other masked controls')
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
testWin = TestMaskedTextCtrls(nb, -1, log)
|
||||
return testWin
|
||||
|
||||
def RunStandalone():
|
||||
app = wxPySimpleApp()
|
||||
frame = wxFrame(None, -1, "Test wxMaskedTextCtrl", size=(640, 480))
|
||||
win = TestMaskedTextCtrls(frame, -1, sys.stdout)
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
#----------------------------------------------------------------------------
|
||||
if __name__ == "__main__":
|
||||
RunStandalone()
|
||||
|
||||
|
||||
overview = """<html>
|
||||
<PRE><FONT SIZE=-1>
|
||||
""" + overviewdoc + """
|
||||
</FONT></PRE>
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
47
wxPython/demo/NewNamespace.py
Normal file
47
wxPython/demo/NewNamespace.py
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
import wx # This module uses the new wx namespace
|
||||
from wx import html
|
||||
from Main import opj
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
hwin = html.HtmlWindow(self, -1)
|
||||
hwin.LoadFile(opj('data/wxPackage.html'))
|
||||
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
sizer.Add(hwin, 1, wx.EXPAND)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>Using the New Namespace</center></h2>
|
||||
|
||||
This sample isn't really a demo, but rather a place to display the
|
||||
introductory doc for using the new namespace.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -136,3 +136,12 @@ and the second will show #2 (<i>working as of 2.3.2</i>)
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
148
wxPython/demo/PopupMenu.py
Normal file
148
wxPython/demo/PopupMenu.py
Normal file
@@ -0,0 +1,148 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
text = """\
|
||||
|
||||
Right-click on the panel (or Ctrl-click on the Mac) to show a popup
|
||||
menu. Then look at the code for this sample. Notice how the
|
||||
PopupMenu method is similar to the ShowModal method of a wxDialog in
|
||||
that it doesn't return until the popup menu has been dismissed. The
|
||||
event handlers for the popup menu items can either be attached to the
|
||||
menu itself, or to the window that invokes PopupMenu.
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
# Make and layout the controls
|
||||
fs = self.GetFont().GetPointSize()
|
||||
bf = wxFont(fs+4, wxSWISS, wxNORMAL, wxBOLD)
|
||||
nf = wxFont(fs+2, wxSWISS, wxNORMAL, wxNORMAL)
|
||||
|
||||
t = wxStaticText(self, -1, "PopupMenu")
|
||||
t.SetFont(bf)
|
||||
box.Add(t, 0, wxCENTER|wxALL, 5)
|
||||
|
||||
box.Add(wxStaticLine(self, -1), 0, wxEXPAND)
|
||||
box.Add(10,20)
|
||||
|
||||
t = wxStaticText(self, -1, text)
|
||||
t.SetFont(nf)
|
||||
box.Add(t, 0, wxCENTER|wxALL, 5)
|
||||
|
||||
self.SetSizer(box)
|
||||
|
||||
EVT_RIGHT_UP(self, self.OnRightClick)
|
||||
|
||||
|
||||
def OnRightClick(self, event):
|
||||
self.log.WriteText("OnRightClick\n")
|
||||
|
||||
# only do this part the first time so the events are only bound once
|
||||
if not hasattr(self, "popupID1"):
|
||||
self.popupID1 = wxNewId()
|
||||
self.popupID2 = wxNewId()
|
||||
self.popupID3 = wxNewId()
|
||||
self.popupID4 = wxNewId()
|
||||
self.popupID5 = wxNewId()
|
||||
self.popupID6 = wxNewId()
|
||||
self.popupID7 = wxNewId()
|
||||
self.popupID8 = wxNewId()
|
||||
self.popupID9 = wxNewId()
|
||||
EVT_MENU(self, self.popupID1, self.OnPopupOne)
|
||||
EVT_MENU(self, self.popupID2, self.OnPopupTwo)
|
||||
EVT_MENU(self, self.popupID3, self.OnPopupThree)
|
||||
EVT_MENU(self, self.popupID4, self.OnPopupFour)
|
||||
EVT_MENU(self, self.popupID5, self.OnPopupFive)
|
||||
EVT_MENU(self, self.popupID6, self.OnPopupSix)
|
||||
EVT_MENU(self, self.popupID7, self.OnPopupSeven)
|
||||
EVT_MENU(self, self.popupID8, self.OnPopupEIght)
|
||||
EVT_MENU(self, self.popupID9, self.OnPopupNine)
|
||||
|
||||
# make a menu
|
||||
menu = wxMenu()
|
||||
# Show how to put an icon in the menu
|
||||
item = wxMenuItem(menu, self.popupID1,"One")
|
||||
item.SetBitmap(images.getSmilesBitmap())
|
||||
menu.AppendItem(item)
|
||||
# add some other items
|
||||
menu.Append(self.popupID2, "Two")
|
||||
menu.Append(self.popupID3, "Three")
|
||||
menu.Append(self.popupID4, "Four")
|
||||
menu.Append(self.popupID5, "Five")
|
||||
menu.Append(self.popupID6, "Six")
|
||||
# make a submenu
|
||||
sm = wxMenu()
|
||||
sm.Append(self.popupID8, "sub item 1")
|
||||
sm.Append(self.popupID9, "sub item 1")
|
||||
menu.AppendMenu(self.popupID7, "Test Submenu", sm)
|
||||
|
||||
|
||||
# Popup the menu. If an item is selected then its handler
|
||||
# will be called before PopupMenu returns.
|
||||
self.PopupMenu(menu, event.GetPosition())
|
||||
menu.Destroy()
|
||||
|
||||
|
||||
def OnPopupOne(self, event):
|
||||
self.log.WriteText("Popup one\n")
|
||||
|
||||
def OnPopupTwo(self, event):
|
||||
self.log.WriteText("Popup two\n")
|
||||
|
||||
def OnPopupThree(self, event):
|
||||
self.log.WriteText("Popup three\n")
|
||||
|
||||
def OnPopupFour(self, event):
|
||||
self.log.WriteText("Popup four\n")
|
||||
|
||||
def OnPopupFive(self, event):
|
||||
self.log.WriteText("Popup five\n")
|
||||
|
||||
def OnPopupSix(self, event):
|
||||
self.log.WriteText("Popup six\n")
|
||||
|
||||
def OnPopupSeven(self, event):
|
||||
self.log.WriteText("Popup seven\n")
|
||||
|
||||
def OnPopupEIght(self, event):
|
||||
self.log.WriteText("Popup eight\n")
|
||||
|
||||
def OnPopupNine(self, event):
|
||||
self.log.WriteText("Popup nine\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>PopupMenu</center></h2>
|
||||
""" + text + """
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -79,7 +79,7 @@ class MyPrintout(wxPrintout):
|
||||
|
||||
#-------------------------------------------
|
||||
|
||||
self.canvas.DoDrawing(dc)
|
||||
self.canvas.DoDrawing(dc, True)
|
||||
dc.DrawText("Page: %d" % page, marginX/2, maxY-marginY)
|
||||
|
||||
return True
|
||||
@@ -176,3 +176,12 @@ def runTest(frame, nb, log):
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -1,20 +1,18 @@
|
||||
|
||||
|
||||
from wxPython.lib.PyCrust import shell, version
|
||||
from wx import py
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % version.VERSION
|
||||
intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % py.version.VERSION
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = shell.Shell(nb, -1, introText=intro)
|
||||
win = py.crust.Crust(nb, intro=intro)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = shell.__doc__
|
||||
|
||||
overview = py.filling.__doc__ + "\n\n" + py.crust.__doc__
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
|
@@ -1,28 +0,0 @@
|
||||
|
||||
from wxPython.wx import wxSplitterWindow
|
||||
from wxPython.lib.PyCrust import shell, version, filling
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % version.VERSION
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxSplitterWindow(nb, -1, size=(640, 480))
|
||||
shellWin = shell.Shell(win, -1, introText=intro)
|
||||
fillingWin = filling.Filling(win, -1, size=(640, 480),
|
||||
rootObject=shellWin.interp.locals,
|
||||
rootIsNamespace=1
|
||||
)
|
||||
win.SplitHorizontally(shellWin, fillingWin)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = filling.__doc__
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
23
wxPython/demo/PyShell.py
Normal file
23
wxPython/demo/PyShell.py
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
from wx import py
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % py.version.VERSION
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = py.shell.Shell(nb, -1, introText=intro)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = py.shell.__doc__
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -83,3 +83,10 @@ This demo is a contrived example of defining an event class in wxPython and send
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
122
wxPython/demo/ShapedWindow.py
Normal file
122
wxPython/demo/ShapedWindow.py
Normal file
@@ -0,0 +1,122 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxFrame.__init__(self, parent, -1, "Shaped Window",
|
||||
style =
|
||||
wxFRAME_SHAPED
|
||||
| wxSIMPLE_BORDER
|
||||
| wxFRAME_NO_TASKBAR
|
||||
| wxSTAY_ON_TOP
|
||||
)
|
||||
|
||||
self.hasShape = False
|
||||
self.delta = wxPoint(0,0)
|
||||
|
||||
EVT_LEFT_DCLICK(self, self.OnDoubleClick)
|
||||
EVT_LEFT_DOWN(self, self.OnLeftDown)
|
||||
EVT_LEFT_UP(self, self.OnLeftUp)
|
||||
EVT_MOTION(self, self.OnMouseMove)
|
||||
EVT_RIGHT_UP(self, self.OnExit)
|
||||
EVT_PAINT(self, self.OnPaint)
|
||||
|
||||
self.bmp = images.getTuxBitmap()
|
||||
w, h = self.bmp.GetWidth(), self.bmp.GetHeight()
|
||||
self.SetClientSize( (w, h) )
|
||||
|
||||
if wxPlatform != "__WXMAC__":
|
||||
# wxMac clips the tooltip to the window shape, YUCK!!!
|
||||
self.SetToolTipString("Right-click to close the window\n"
|
||||
"Double-click the image to set/unset the window shape")
|
||||
|
||||
if wxPlatform == "__WXGTK__":
|
||||
# wxGTK requires that the window be created before you can
|
||||
# set its shape, so delay the call to SetWindowShape until
|
||||
# this event.
|
||||
EVT_WINDOW_CREATE(self, self.SetWindowShape)
|
||||
else:
|
||||
# On wxMSW and wxMac the window has already been created, so go for it.
|
||||
self.SetWindowShape()
|
||||
|
||||
dc = wxClientDC(self)
|
||||
dc.DrawBitmap(self.bmp, 0,0, True)
|
||||
|
||||
|
||||
def SetWindowShape(self, *evt):
|
||||
# Use the bitmap's mask to determine the region
|
||||
r = wxRegionFromBitmap(self.bmp)
|
||||
self.hasShape = self.SetShape(r)
|
||||
|
||||
|
||||
def OnDoubleClick(self, evt):
|
||||
if self.hasShape:
|
||||
self.SetShape(wxRegion())
|
||||
self.hasShape = False
|
||||
else:
|
||||
self.SetWindowShape()
|
||||
|
||||
|
||||
def OnPaint(self, evt):
|
||||
dc = wxPaintDC(self)
|
||||
dc.DrawBitmap(self.bmp, 0,0, True)
|
||||
|
||||
def OnExit(self, evt):
|
||||
self.Close()
|
||||
|
||||
|
||||
def OnLeftDown(self, evt):
|
||||
self.CaptureMouse()
|
||||
pos = self.ClientToScreen(evt.GetPosition())
|
||||
origin = self.GetPosition()
|
||||
dx = pos.x - origin.x
|
||||
dy = pos.y - origin.y
|
||||
self.delta = wxPoint(dx, dy)
|
||||
|
||||
|
||||
def OnLeftUp(self, evt):
|
||||
if self.HasCapture():
|
||||
self.ReleaseMouse()
|
||||
|
||||
|
||||
def OnMouseMove(self, evt):
|
||||
if evt.Dragging() and evt.LeftIsDown():
|
||||
pos = self.ClientToScreen(evt.GetPosition())
|
||||
fp = (pos.x - self.delta.x, pos.y - self.delta.y)
|
||||
self.Move(fp)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestFrame(nb, log)
|
||||
frame.otherWin = win
|
||||
win.Show(True)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>Shaped Window</center></h2>
|
||||
|
||||
Top level windows now have a SetShape method that lets you set a
|
||||
non-rectangular shape for the window using a wxRegion. All pixels
|
||||
outside of the region will not be drawn and the window will not be
|
||||
sensitive to the mouse in those areas either.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -141,11 +141,11 @@ def makeBoxInBox(win):
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
box2.AddMany([ (wxButton(win, 1010, "two"), 0, wxEXPAND),
|
||||
(wxButton(win, 1010, "three"), 0, wxEXPAND),
|
||||
(wxButton(win, 1010, "four"), 0, wxEXPAND),
|
||||
(wxButton(win, 1010, "five"), 0, wxEXPAND),
|
||||
])
|
||||
box2.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
|
||||
btn3 = wxButton(win, 1010, "three")
|
||||
box2.Add(btn3, 0, wxEXPAND)
|
||||
box2.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
|
||||
box2.Add(wxButton(win, 1010, "five"), 0, wxEXPAND)
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxEXPAND),
|
||||
@@ -159,6 +159,8 @@ def makeBoxInBox(win):
|
||||
|
||||
box.Add(wxButton(win, 1010, "ten"), 0, wxEXPAND)
|
||||
|
||||
##box.Hide(btn3)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@@ -1,379 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
"""This is SlashDot 1.2
|
||||
|
||||
It's the obligatory Slashdot.org headlines reader that
|
||||
any modern widget set/library must have in order to be taken
|
||||
seriously :-)
|
||||
|
||||
Usage is quite simple; wxSlash attempts to download the
|
||||
'ultramode.txt' file from http://slashdot.org, which
|
||||
contains the headlines in a computer friendly format. It
|
||||
then displays said headlines in a wxWindows list control.
|
||||
|
||||
You can read articles using either Python's html library
|
||||
or an external browser. Uncheck the 'browser->internal' menu
|
||||
item to use the latter option. Use the settings dialog box
|
||||
to set which external browser is started.
|
||||
|
||||
This code is available under the wxWindows license, see
|
||||
elsewhere. If you modify this code, be aware of the fact
|
||||
that slashdot.org's maintainer, CmdrTaco, explicitly asks
|
||||
'ultramode.txt' downloaders not to do this automatically
|
||||
more than twice per hour. If this feature is abused,
|
||||
CmdrTaco may remove the ultramode file completely and that
|
||||
will make a *lot* of people unhappy.
|
||||
|
||||
I want to thank Alex Shnitman whose slashes.pl
|
||||
(Perl/GTK) script gave me the idea for this applet.
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
from httplib import HTTP
|
||||
from htmllib import HTMLParser
|
||||
import os
|
||||
import re
|
||||
import formatter
|
||||
|
||||
class HTMLTextView(wxFrame):
|
||||
def __init__(self, parent, id, title='HTMLTextView', url=None):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(600,400))
|
||||
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(201, '&Open URL...', 'Open URL')
|
||||
EVT_MENU(self, 201, self.OnFileOpen)
|
||||
menu.Append(209, 'E&xit', 'Exit viewer')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
self.CreateStatusBar(1)
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "", wxPyDefaultPosition,
|
||||
wxPyDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
|
||||
|
||||
if (url):
|
||||
self.OpenURL(url)
|
||||
|
||||
def logprint(self, x):
|
||||
self.SetStatusText(x)
|
||||
|
||||
def OpenURL(self, url):
|
||||
self.url = url
|
||||
m = re.match('file:(\S+)\s*', url)
|
||||
if m:
|
||||
f = open(m.groups()[0],'r')
|
||||
else:
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = RetrieveAsFile(host,path,self.logprint)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('tmphtml.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
tmp = open('tmphtml.txt', 'r')
|
||||
self.text.SetValue(tmp.read())
|
||||
self.SetTitle(url)
|
||||
self.logprint(url)
|
||||
|
||||
def OnFileOpen(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter URL to open:", "")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
url = dlg.GetValue()
|
||||
else:
|
||||
url = None
|
||||
if url:
|
||||
self.OpenURL(url)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Close()
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
def ParseSlashdot(f):
|
||||
art_sep = re.compile('%%\r?\n')
|
||||
line_sep = re.compile('\r?\n')
|
||||
data = f.read()
|
||||
list = art_sep.split(data)
|
||||
art_list = []
|
||||
for i in range(1,len(list)-1):
|
||||
art_list.append(line_sep.split(list[i]))
|
||||
return art_list
|
||||
|
||||
def myprint(x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(host, path='', logprint = myprint):
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
# f = open('/home/harm/ultramode.txt','r')
|
||||
return f
|
||||
|
||||
|
||||
class AppStatusBar(wxStatusBar):
|
||||
def __init__(self, parent):
|
||||
wxStatusBar.__init__(self,parent, -1)
|
||||
self.SetFieldsCount(2)
|
||||
self.SetStatusWidths([-1, 100])
|
||||
self.but = wxButton(self, 1001, "Refresh")
|
||||
EVT_BUTTON(self, 1001, parent.OnViewRefresh)
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
self.OnSize(None)
|
||||
|
||||
def logprint(self,x):
|
||||
self.SetStatusText(x,0)
|
||||
|
||||
def OnSize(self, event):
|
||||
rect = self.GetFieldRect(1)
|
||||
self.but.SetPosition(wxPoint(rect.x+2, rect.y+2))
|
||||
self.but.SetSize(wxSize(rect.width-4, rect.height-4))
|
||||
|
||||
# This is a simple timer class to start a function after a short delay;
|
||||
class QuickTimer(wxTimer):
|
||||
def __init__(self, func, wait=100):
|
||||
wxTimer.__init__(self)
|
||||
self.callback = func
|
||||
self.Start(wait); # wait .1 second (.001 second doesn't work. why?)
|
||||
def Notify(self):
|
||||
self.Stop();
|
||||
apply(self.callback, ());
|
||||
|
||||
class AppFrame(wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(650, 250))
|
||||
|
||||
# if the window manager closes the window:
|
||||
EVT_CLOSE(self, self.OnCloseWindow);
|
||||
|
||||
# Now Create the menu bar and items
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(209, 'E&xit', 'Enough of this already!')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
menu = wxMenu()
|
||||
menu.Append(210, '&Refresh', 'Refresh headlines')
|
||||
EVT_MENU(self, 210, self.OnViewRefresh)
|
||||
menu.Append(211, '&Slashdot Index', 'View Slashdot index')
|
||||
EVT_MENU(self, 211, self.OnViewIndex)
|
||||
menu.Append(212, 'Selected &Article', 'View selected article')
|
||||
EVT_MENU(self, 212, self.OnViewArticle)
|
||||
self.mainmenu.Append(menu, '&View')
|
||||
menu = wxMenu()
|
||||
menu.Append(220, '&Internal', 'Use internal text browser',True)
|
||||
menu.Check(220, True)
|
||||
self.UseInternal = 1;
|
||||
EVT_MENU(self, 220, self.OnBrowserInternal)
|
||||
menu.Append(222, '&Settings...', 'External browser Settings')
|
||||
EVT_MENU(self, 222, self.OnBrowserSettings)
|
||||
self.mainmenu.Append(menu, '&Browser')
|
||||
menu = wxMenu()
|
||||
menu.Append(230, '&About', 'Some documentation');
|
||||
EVT_MENU(self, 230, self.OnAbout)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
if wxPlatform == '__WXGTK__':
|
||||
# I like lynx. Also Netscape 4.5 doesn't react to my cmdline opts
|
||||
self.BrowserSettings = "xterm -e lynx %s &"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
# netscape 4.x likes to hang out here...
|
||||
self.BrowserSettings = '\\progra~1\\Netscape\\Communicator\\Program\\netscape.exe %s'
|
||||
else:
|
||||
# a wild guess...
|
||||
self.BrowserSettings = 'netscape %s'
|
||||
|
||||
# A status bar to tell people what's happening
|
||||
self.sb = AppStatusBar(self)
|
||||
self.SetStatusBar(self.sb)
|
||||
|
||||
self.list = wxListCtrl(self, 1100, style=wxLC_REPORT)
|
||||
self.list.InsertColumn(0, 'Subject')
|
||||
self.list.InsertColumn(1, 'Date')
|
||||
self.list.InsertColumn(2, 'Posted by')
|
||||
self.list.InsertColumn(3, 'Comments')
|
||||
self.list.SetColumnWidth(0, 300)
|
||||
self.list.SetColumnWidth(1, 150)
|
||||
self.list.SetColumnWidth(2, 100)
|
||||
self.list.SetColumnWidth(3, 100)
|
||||
|
||||
EVT_LIST_ITEM_SELECTED(self, 1100, self.OnItemSelected)
|
||||
EVT_LEFT_DCLICK(self.list, self.OnLeftDClick)
|
||||
|
||||
self.logprint("Connecting to slashdot... Please wait.")
|
||||
# wxYield doesn't yet work here. That's why we use a timer
|
||||
# to make sure that we see some GUI stuff before the slashdot
|
||||
# file is transfered.
|
||||
self.timer = QuickTimer(self.DoRefresh, 1000)
|
||||
|
||||
def logprint(self, x):
|
||||
self.sb.logprint(x)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def DoRefresh(self):
|
||||
f = RetrieveAsFile('slashdot.org','/ultramode.txt',self.sb.logprint)
|
||||
art_list = ParseSlashdot(f)
|
||||
self.list.DeleteAllItems()
|
||||
self.url = []
|
||||
self.current = -1
|
||||
i = 0;
|
||||
for article in art_list:
|
||||
self.list.InsertStringItem(i, article[0])
|
||||
self.list.SetStringItem(i, 1, article[2])
|
||||
self.list.SetStringItem(i, 2, article[3])
|
||||
self.list.SetStringItem(i, 3, article[6])
|
||||
self.url.append(article[1])
|
||||
i = i + 1
|
||||
self.logprint("File retrieved OK.")
|
||||
|
||||
def OnViewRefresh(self, event):
|
||||
self.logprint("Connecting to slashdot... Please wait.");
|
||||
wxYield()
|
||||
self.DoRefresh()
|
||||
|
||||
def DoViewIndex(self):
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, 'slashdot.org',
|
||||
'http://slashdot.org')
|
||||
self.view.Show(True)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % ('http://slashdot.org'))
|
||||
#os.system(self.BrowserSettings % ('http://slashdot.org'))
|
||||
wxExecute(self.BrowserSettings % ('http://slashdot.org'))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewIndex(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewIndex()
|
||||
|
||||
def DoViewArticle(self):
|
||||
if self.current<0: return
|
||||
url = self.url[self.current]
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, url, url)
|
||||
self.view.Show(True)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % (url))
|
||||
os.system(self.BrowserSettings % (url))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewArticle(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewArticle()
|
||||
|
||||
def OnBrowserInternal(self, event):
|
||||
if self.mainmenu.Checked(220):
|
||||
self.UseInternal = 1
|
||||
else:
|
||||
self.UseInternal = 0
|
||||
|
||||
def OnBrowserSettings(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter command to view URL.\nUse %s as a placeholder for the URL.", "", self.BrowserSettings);
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.BrowserSettings = dlg.GetValue()
|
||||
|
||||
def OnAbout(self, event):
|
||||
dlg = wxMessageDialog(self, __doc__, "wxSlash", wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
|
||||
def OnItemSelected(self, event):
|
||||
self.current = event.m_itemIndex
|
||||
self.logprint("URL: %s" % (self.url[self.current]))
|
||||
|
||||
def OnLeftDClick(self, event):
|
||||
(x,y) = event.Position();
|
||||
# Actually, we should convert x,y to logical coords using
|
||||
# a dc, but only for a wxScrolledWindow widget.
|
||||
# Now wxGTK derives wxListCtrl from wxScrolledWindow,
|
||||
# and wxMSW from wxControl... So that doesn't work.
|
||||
#dc = wxClientDC(self.list)
|
||||
##self.list.PrepareDC(dc)
|
||||
#x = dc.DeviceToLogicalX( event.GetX() )
|
||||
#y = dc.DeviceToLogicalY( event.GetY() )
|
||||
id = self.list.HitTest(wxPoint(x,y))
|
||||
#print "Double click at %d %d" % (x,y), id
|
||||
# Okay, we got a double click. Let's assume it's the current selection
|
||||
wxYield()
|
||||
self.OnViewArticle(event)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running standalone
|
||||
|
||||
if __name__ == '__main__':
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = AppFrame(None, -1, "Slashdot Breaking News")
|
||||
frame.Show(True)
|
||||
self.SetTopWindow(frame)
|
||||
return True
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running as part of the Demo Framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = AppFrame(None, -1, "Slashdot Breaking News")
|
||||
frame.otherWin = win
|
||||
win.Show(True)
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
@@ -205,3 +205,12 @@ when the framework allows for it.
|
||||
|
||||
""" % os.path.join(os.path.dirname(wxPython.lib.printout.__file__), "printout.py")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -244,3 +244,11 @@ ProcessEvent does, it processes it later from the context of the GUI
|
||||
thread.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -121,3 +121,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -139,3 +139,12 @@ and then pass the unicode to the wxPython method.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -110,3 +110,11 @@ else:
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
BIN
wxPython/demo/bmp_source/Tux.png
Normal file
BIN
wxPython/demo/bmp_source/Tux.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>/home/others/projects/wx2.3/contrib/include/wx/stc/stc.h.html</title>
|
||||
<meta name="Generator" content="Vim/6.0">
|
||||
<title>/home/work/projects/wx2.4/contrib/include/wx/stc/stc.h.html</title>
|
||||
<meta name="Generator" content="Vim/6.1">
|
||||
</head>
|
||||
<body bgcolor="#f5deb3" text="#000000">
|
||||
<pre>
|
||||
@@ -31,6 +31,30 @@
|
||||
<font color="#a020f0">#include </font><font color="#ff00ff"><wx/wx.h></font>
|
||||
<font color="#a020f0">#include </font><font color="#ff00ff"><wx/dnd.h></font>
|
||||
|
||||
<font color="#a020f0">#ifndef SWIG</font>
|
||||
<font color="#0000ff">/*</font>
|
||||
<font color="#0000ff"> * If we're using wx in Dynamic Library format do we</font>
|
||||
<font color="#0000ff"> * want wxStyledTextCtrl to be in DLL form as well?</font>
|
||||
<font color="#0000ff"> */</font>
|
||||
<font color="#a020f0">#if defined(WXUSINGDLL) && \</font>
|
||||
<font color="#a020f0"> (defined(WXMAKING_STC_DLL) || defined(WXUSING_STC_DLL))</font>
|
||||
|
||||
<font color="#a020f0">#if defined(WXMAKING_STC_DLL)</font>
|
||||
<font color="#0000ff">// When building the DLL WXSTC_DECLSPEC exports classes</font>
|
||||
<font color="#a020f0"># define WXSTC_DECLSPEC WXEXPORT</font>
|
||||
<font color="#a020f0">#elif defined(WXUSING_STC_DLL)</font>
|
||||
<font color="#0000ff">// When using the DLL WXSTC_DECLSPEC imports classes</font>
|
||||
<font color="#a020f0"># define WXSTC_DECLSPEC WXIMPORT</font>
|
||||
<font color="#a020f0">#endif</font> <font color="#0000ff">// defined(WXBUILD_STC_DLL)</font>
|
||||
|
||||
<font color="#a020f0">#else</font>
|
||||
<font color="#0000ff">// When building the static library nullify the effect of WXSTC_DECLSPEC</font>
|
||||
<font color="#a020f0">#define WXSTC_DECLSPEC</font>
|
||||
<font color="#a020f0">#endif</font> <font color="#0000ff">// WXUSINGDLL && (WXMAKING_STC_DLL || WXUSING_STC_DLL)</font>
|
||||
|
||||
<font color="#a020f0">#endif</font> <font color="#0000ff">// SWIG</font>
|
||||
|
||||
|
||||
<font color="#0000ff">//----------------------------------------------------------------------</font>
|
||||
|
||||
<font color="#0000ff">// Should a wxPopupWindow be used for the call tips and autocomplete windows?</font>
|
||||
@@ -50,12 +74,6 @@
|
||||
<font color="#a020f0">#define wxSTC_START </font><font color="#ff00ff">2000</font>
|
||||
<font color="#a020f0">#define wxSTC_OPTIONAL_START </font><font color="#ff00ff">3000</font>
|
||||
<font color="#a020f0">#define wxSTC_LEXER_START </font><font color="#ff00ff">4000</font>
|
||||
|
||||
<font color="#0000ff">// Redoes the next action on the undo history.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_REDO </font><font color="#ff00ff">2011</font>
|
||||
|
||||
<font color="#0000ff">// Select all the text in the document.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_SELECTALL </font><font color="#ff00ff">2013</font>
|
||||
<font color="#a020f0">#define wxSTC_WS_INVISIBLE </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_WS_VISIBLEALWAYS </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_WS_VISIBLEAFTERINDENT </font><font color="#ff00ff">2</font>
|
||||
@@ -66,6 +84,9 @@
|
||||
<font color="#0000ff">// The SC_CP_UTF8 value can be used to enter Unicode mode.</font>
|
||||
<font color="#0000ff">// This is the same value as CP_UTF8 in Windows</font>
|
||||
<font color="#a020f0">#define wxSTC_CP_UTF8 </font><font color="#ff00ff">65001</font>
|
||||
|
||||
<font color="#0000ff">// The SC_CP_DBCS value can be used to indicate a DBCS mode for GTK+.</font>
|
||||
<font color="#a020f0">#define wxSTC_CP_DBCS </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_MARKER_MAX </font><font color="#ff00ff">31</font>
|
||||
<font color="#a020f0">#define wxSTC_MARK_CIRCLE </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_MARK_ROUNDRECT </font><font color="#ff00ff">1</font>
|
||||
@@ -96,6 +117,7 @@
|
||||
<font color="#a020f0">#define wxSTC_MARK_BACKGROUND </font><font color="#ff00ff">22</font>
|
||||
<font color="#a020f0">#define wxSTC_MARK_DOTDOTDOT </font><font color="#ff00ff">23</font>
|
||||
<font color="#a020f0">#define wxSTC_MARK_ARROWS </font><font color="#ff00ff">24</font>
|
||||
<font color="#a020f0">#define wxSTC_MARK_PIXMAP </font><font color="#ff00ff">25</font>
|
||||
<font color="#a020f0">#define wxSTC_MARK_CHARACTER </font><font color="#ff00ff">10000</font>
|
||||
|
||||
<font color="#0000ff">// Markers used for outlining column.</font>
|
||||
@@ -174,22 +196,20 @@
|
||||
<font color="#a020f0">#define wxSTC_FIND_MATCHCASE </font><font color="#ff00ff">4</font>
|
||||
<font color="#a020f0">#define wxSTC_FIND_WORDSTART </font><font color="#ff00ff">0x00100000</font>
|
||||
<font color="#a020f0">#define wxSTC_FIND_REGEXP </font><font color="#ff00ff">0x00200000</font>
|
||||
|
||||
<font color="#0000ff">// Undo one action in the undo history.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_UNDO </font><font color="#ff00ff">2176</font>
|
||||
|
||||
<font color="#0000ff">// Cut the selection to the clipboard.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CUT </font><font color="#ff00ff">2177</font>
|
||||
|
||||
<font color="#0000ff">// Copy the selection to the clipboard.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_COPY </font><font color="#ff00ff">2178</font>
|
||||
|
||||
<font color="#0000ff">// Paste the contents of the clipboard into the document replacing the selection.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PASTE </font><font color="#ff00ff">2179</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELBASE </font><font color="#ff00ff">0x400</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELWHITEFLAG </font><font color="#ff00ff">0x1000</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELHEADERFLAG </font><font color="#ff00ff">0x2000</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELBOXHEADERFLAG </font><font color="#ff00ff">0x4000</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELBOXFOOTERFLAG </font><font color="#ff00ff">0x8000</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELCONTRACTED </font><font color="#ff00ff">0x10000</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELUNINDENT </font><font color="#ff00ff">0x20000</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDLEVELNUMBERMASK </font><font color="#ff00ff">0x0FFF</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDFLAG_LINEBEFORE_EXPANDED </font><font color="#ff00ff">0x0002</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED </font><font color="#ff00ff">0x0004</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDFLAG_LINEAFTER_EXPANDED </font><font color="#ff00ff">0x0008</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED </font><font color="#ff00ff">0x0010</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDFLAG_LEVELNUMBERS </font><font color="#ff00ff">0x0040</font>
|
||||
<font color="#a020f0">#define wxSTC_FOLDFLAG_BOX </font><font color="#ff00ff">0x0001</font>
|
||||
<font color="#a020f0">#define wxSTC_TIME_FOREVER </font><font color="#ff00ff">10000000</font>
|
||||
<font color="#a020f0">#define wxSTC_WRAP_NONE </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_WRAP_WORD </font><font color="#ff00ff">1</font>
|
||||
@@ -197,163 +217,11 @@
|
||||
<font color="#a020f0">#define wxSTC_CACHE_CARET </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_CACHE_PAGE </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_CACHE_DOCUMENT </font><font color="#ff00ff">3</font>
|
||||
|
||||
<font color="#0000ff">// Move caret down one line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEDOWN </font><font color="#ff00ff">2300</font>
|
||||
|
||||
<font color="#0000ff">// Move caret down one line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEDOWNEXTEND </font><font color="#ff00ff">2301</font>
|
||||
|
||||
<font color="#0000ff">// Move caret up one line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEUP </font><font color="#ff00ff">2302</font>
|
||||
|
||||
<font color="#0000ff">// Move caret up one line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEUPEXTEND </font><font color="#ff00ff">2303</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one character.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARLEFT </font><font color="#ff00ff">2304</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one character extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARLEFTEXTEND </font><font color="#ff00ff">2305</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one character.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARRIGHT </font><font color="#ff00ff">2306</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one character extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARRIGHTEXTEND </font><font color="#ff00ff">2307</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one word.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDLEFT </font><font color="#ff00ff">2308</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one word extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDLEFTEXTEND </font><font color="#ff00ff">2309</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one word.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDRIGHT </font><font color="#ff00ff">2310</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one word extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDRIGHTEXTEND </font><font color="#ff00ff">2311</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOME </font><font color="#ff00ff">2312</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOMEEXTEND </font><font color="#ff00ff">2313</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEEND </font><font color="#ff00ff">2314</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEENDEXTEND </font><font color="#ff00ff">2315</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position in document.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTSTART </font><font color="#ff00ff">2316</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position in document extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTSTARTEXTEND </font><font color="#ff00ff">2317</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position in document.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTEND </font><font color="#ff00ff">2318</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position in document extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTENDEXTEND </font><font color="#ff00ff">2319</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page up.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEUP </font><font color="#ff00ff">2320</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page up extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEUPEXTEND </font><font color="#ff00ff">2321</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page down.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEDOWN </font><font color="#ff00ff">2322</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page down extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEDOWNEXTEND </font><font color="#ff00ff">2323</font>
|
||||
|
||||
<font color="#0000ff">// Switch from insert to overtype mode or the reverse.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_EDITTOGGLEOVERTYPE </font><font color="#ff00ff">2324</font>
|
||||
|
||||
<font color="#0000ff">// Cancel any modes such as call tip or auto-completion list display.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CANCEL </font><font color="#ff00ff">2325</font>
|
||||
|
||||
<font color="#0000ff">// Delete the selection or if no selection, the character before the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELETEBACK </font><font color="#ff00ff">2326</font>
|
||||
|
||||
<font color="#0000ff">// If selection is empty or all on one line replace the selection with a tab character.</font>
|
||||
<font color="#0000ff">// If more than one line selected, indent the lines.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_TAB </font><font color="#ff00ff">2327</font>
|
||||
|
||||
<font color="#0000ff">// Dedent the selected lines.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_BACKTAB </font><font color="#ff00ff">2328</font>
|
||||
|
||||
<font color="#0000ff">// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_NEWLINE </font><font color="#ff00ff">2329</font>
|
||||
|
||||
<font color="#0000ff">// Insert a Form Feed character.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_FORMFEED </font><font color="#ff00ff">2330</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to before first visible character on line.</font>
|
||||
<font color="#0000ff">// If already there move to first character on line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_VCHOME </font><font color="#ff00ff">2331</font>
|
||||
|
||||
<font color="#0000ff">// Like VCHome but extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_VCHOMEEXTEND </font><font color="#ff00ff">2332</font>
|
||||
|
||||
<font color="#0000ff">// Magnify the displayed text by increasing the sizes by 1 point.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_ZOOMIN </font><font color="#ff00ff">2333</font>
|
||||
|
||||
<font color="#0000ff">// Make the displayed text smaller by decreasing the sizes by 1 point.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_ZOOMOUT </font><font color="#ff00ff">2334</font>
|
||||
|
||||
<font color="#0000ff">// Delete the word to the left of the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELWORDLEFT </font><font color="#ff00ff">2335</font>
|
||||
|
||||
<font color="#0000ff">// Delete the word to the right of the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELWORDRIGHT </font><font color="#ff00ff">2336</font>
|
||||
|
||||
<font color="#0000ff">// Cut the line containing the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINECUT </font><font color="#ff00ff">2337</font>
|
||||
|
||||
<font color="#0000ff">// Delete the line containing the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEDELETE </font><font color="#ff00ff">2338</font>
|
||||
|
||||
<font color="#0000ff">// Switch the current line with the previous.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINETRANSPOSE </font><font color="#ff00ff">2339</font>
|
||||
|
||||
<font color="#0000ff">// Transform the selection to lower case.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LOWERCASE </font><font color="#ff00ff">2340</font>
|
||||
|
||||
<font color="#0000ff">// Transform the selection to upper case.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_UPPERCASE </font><font color="#ff00ff">2341</font>
|
||||
|
||||
<font color="#0000ff">// Scroll the document down, keeping the caret visible.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINESCROLLDOWN </font><font color="#ff00ff">2342</font>
|
||||
|
||||
<font color="#0000ff">// Scroll the document up, keeping the caret visible.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINESCROLLUP </font><font color="#ff00ff">2343</font>
|
||||
|
||||
<font color="#0000ff">// Delete the selection or if no selection, the character before the caret.</font>
|
||||
<font color="#0000ff">// Will not delete the character before at the start of a line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELETEBACKNOTLINE </font><font color="#ff00ff">2344</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on display line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOMEDISPLAY </font><font color="#ff00ff">2345</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on display line extending selection to </font>
|
||||
<font color="#0000ff">// new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOMEDISPLAYEXTEND </font><font color="#ff00ff">2346</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on display line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEENDDISPLAY </font><font color="#ff00ff">2347</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on display line extending selection to new </font>
|
||||
<font color="#0000ff">// caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEENDDISPLAYEXTEND </font><font color="#ff00ff">2348</font>
|
||||
<font color="#a020f0">#define wxSTC_EDGE_NONE </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_EDGE_LINE </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_EDGE_BACKGROUND </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_CURSORNORMAL -</font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_CURSORWAIT </font><font color="#ff00ff">3</font>
|
||||
<font color="#a020f0">#define wxSTC_CURSORWAIT </font><font color="#ff00ff">4</font>
|
||||
|
||||
<font color="#0000ff">// Constants for use with SetVisiblePolicy, similar to SetCaretPolicy.</font>
|
||||
<font color="#a020f0">#define wxSTC_VISIBLE_SLOP </font><font color="#ff00ff">0x01</font>
|
||||
@@ -461,6 +329,11 @@
|
||||
<font color="#a020f0">#define wxSTC_LEX_BAAN </font><font color="#ff00ff">31</font>
|
||||
<font color="#a020f0">#define wxSTC_LEX_MATLAB </font><font color="#ff00ff">32</font>
|
||||
<font color="#a020f0">#define wxSTC_LEX_SCRIPTOL </font><font color="#ff00ff">33</font>
|
||||
<font color="#a020f0">#define wxSTC_LEX_ASM </font><font color="#ff00ff">34</font>
|
||||
<font color="#a020f0">#define wxSTC_LEX_CPPNOCASE </font><font color="#ff00ff">35</font>
|
||||
<font color="#a020f0">#define wxSTC_LEX_FORTRAN </font><font color="#ff00ff">36</font>
|
||||
<font color="#a020f0">#define wxSTC_LEX_F77 </font><font color="#ff00ff">37</font>
|
||||
<font color="#a020f0">#define wxSTC_LEX_CSS </font><font color="#ff00ff">38</font>
|
||||
|
||||
<font color="#0000ff">// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a</font>
|
||||
<font color="#0000ff">// value assigned in sequence from SCLEX_AUTOMATIC+1.</font>
|
||||
@@ -729,6 +602,7 @@
|
||||
<font color="#a020f0">#define wxSTC_ERR_DIFF_ADDITION </font><font color="#ff00ff">11</font>
|
||||
<font color="#a020f0">#define wxSTC_ERR_DIFF_DELETION </font><font color="#ff00ff">12</font>
|
||||
<font color="#a020f0">#define wxSTC_ERR_DIFF_MESSAGE </font><font color="#ff00ff">13</font>
|
||||
<font color="#a020f0">#define wxSTC_ERR_PHP </font><font color="#ff00ff">14</font>
|
||||
|
||||
<font color="#0000ff">// Lexical states for SCLEX_BATCH</font>
|
||||
<font color="#a020f0">#define wxSTC_BAT_DEFAULT </font><font color="#ff00ff">0</font>
|
||||
@@ -775,24 +649,31 @@
|
||||
<font color="#a020f0">#define wxSTC_AVE_COMMENT </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_NUMBER </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_WORD </font><font color="#ff00ff">3</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_KEYWORD </font><font color="#ff00ff">4</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_STATEMENT </font><font color="#ff00ff">5</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_STRING </font><font color="#ff00ff">6</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_ENUM </font><font color="#ff00ff">7</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_STRINGEOL </font><font color="#ff00ff">8</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_IDENTIFIER </font><font color="#ff00ff">9</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_OPERATOR </font><font color="#ff00ff">10</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_WORD1 </font><font color="#ff00ff">11</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_WORD2 </font><font color="#ff00ff">12</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_WORD3 </font><font color="#ff00ff">13</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_WORD4 </font><font color="#ff00ff">14</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_WORD5 </font><font color="#ff00ff">15</font>
|
||||
<font color="#a020f0">#define wxSTC_AVE_WORD6 </font><font color="#ff00ff">16</font>
|
||||
|
||||
<font color="#0000ff">// Lexical states for SCLEX_ADA</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_DEFAULT </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_COMMENT </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_NUMBER </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_WORD </font><font color="#ff00ff">3</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_STRING </font><font color="#ff00ff">4</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_WORD </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_IDENTIFIER </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_NUMBER </font><font color="#ff00ff">3</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_DELIMITER </font><font color="#ff00ff">4</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_CHARACTER </font><font color="#ff00ff">5</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_OPERATOR </font><font color="#ff00ff">6</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_IDENTIFIER </font><font color="#ff00ff">7</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_CHARACTEREOL </font><font color="#ff00ff">6</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_STRING </font><font color="#ff00ff">7</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_STRINGEOL </font><font color="#ff00ff">8</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_LABEL </font><font color="#ff00ff">9</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_COMMENTLINE </font><font color="#ff00ff">10</font>
|
||||
<font color="#a020f0">#define wxSTC_ADA_ILLEGAL </font><font color="#ff00ff">11</font>
|
||||
|
||||
<font color="#0000ff">// Lexical states for SCLEX_BAAN</font>
|
||||
<font color="#a020f0">#define wxSTC_BAAN_DEFAULT </font><font color="#ff00ff">0</font>
|
||||
@@ -873,6 +754,252 @@
|
||||
<font color="#a020f0">#define wxSTC_SCRIPTOL_COMMENTDOCKEYWORDERROR </font><font color="#ff00ff">18</font>
|
||||
<font color="#a020f0">#define wxSTC_SCRIPTOL_COMMENTBASIC </font><font color="#ff00ff">19</font>
|
||||
|
||||
<font color="#0000ff">// Lexical states for SCLEX_ASM</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_DEFAULT </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_COMMENT </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_NUMBER </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_STRING </font><font color="#ff00ff">3</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_OPERATOR </font><font color="#ff00ff">4</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_IDENTIFIER </font><font color="#ff00ff">5</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_CPUINSTRUCTION </font><font color="#ff00ff">6</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_MATHINSTRUCTION </font><font color="#ff00ff">7</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_REGISTER </font><font color="#ff00ff">8</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_DIRECTIVE </font><font color="#ff00ff">9</font>
|
||||
<font color="#a020f0">#define wxSTC_ASM_DIRECTIVEOPERAND </font><font color="#ff00ff">10</font>
|
||||
|
||||
<font color="#0000ff">// Lexical states for SCLEX_FORTRAN</font>
|
||||
<font color="#a020f0">#define wxSTC_F_DEFAULT </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_F_COMMENT </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_F_NUMBER </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_F_STRING1 </font><font color="#ff00ff">3</font>
|
||||
<font color="#a020f0">#define wxSTC_F_STRING2 </font><font color="#ff00ff">4</font>
|
||||
<font color="#a020f0">#define wxSTC_F_STRINGEOL </font><font color="#ff00ff">5</font>
|
||||
<font color="#a020f0">#define wxSTC_F_OPERATOR </font><font color="#ff00ff">6</font>
|
||||
<font color="#a020f0">#define wxSTC_F_IDENTIFIER </font><font color="#ff00ff">7</font>
|
||||
<font color="#a020f0">#define wxSTC_F_WORD </font><font color="#ff00ff">8</font>
|
||||
<font color="#a020f0">#define wxSTC_F_WORD2 </font><font color="#ff00ff">9</font>
|
||||
<font color="#a020f0">#define wxSTC_F_WORD3 </font><font color="#ff00ff">10</font>
|
||||
<font color="#a020f0">#define wxSTC_F_PREPROCESSOR </font><font color="#ff00ff">11</font>
|
||||
<font color="#a020f0">#define wxSTC_F_OPERATOR2 </font><font color="#ff00ff">12</font>
|
||||
<font color="#a020f0">#define wxSTC_F_LABEL </font><font color="#ff00ff">13</font>
|
||||
<font color="#a020f0">#define wxSTC_F_CONTINUATION </font><font color="#ff00ff">14</font>
|
||||
|
||||
<font color="#0000ff">// Lexical states for SCLEX_CSS</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_DEFAULT </font><font color="#ff00ff">0</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_TAG </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_CLASS </font><font color="#ff00ff">2</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_PSEUDOCLASS </font><font color="#ff00ff">3</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_UNKNOWN_PSEUDOCLASS </font><font color="#ff00ff">4</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_OPERATOR </font><font color="#ff00ff">5</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_IDENTIFIER </font><font color="#ff00ff">6</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_UNKNOWN_IDENTIFIER </font><font color="#ff00ff">7</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_VALUE </font><font color="#ff00ff">8</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_COMMENT </font><font color="#ff00ff">9</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_ID </font><font color="#ff00ff">10</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_IMPORTANT </font><font color="#ff00ff">11</font>
|
||||
<font color="#a020f0">#define wxSTC_CSS_DIRECTIVE </font><font color="#ff00ff">12</font>
|
||||
|
||||
|
||||
<font color="#0000ff">//-----------------------------------------</font>
|
||||
<font color="#0000ff">// Commands that can be bound to keystrokes</font>
|
||||
|
||||
<font color="#0000ff">// Redoes the next action on the undo history.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_REDO </font><font color="#ff00ff">2011</font>
|
||||
|
||||
<font color="#0000ff">// Select all the text in the document.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_SELECTALL </font><font color="#ff00ff">2013</font>
|
||||
|
||||
<font color="#0000ff">// Undo one action in the undo history.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_UNDO </font><font color="#ff00ff">2176</font>
|
||||
|
||||
<font color="#0000ff">// Cut the selection to the clipboard.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CUT </font><font color="#ff00ff">2177</font>
|
||||
|
||||
<font color="#0000ff">// Copy the selection to the clipboard.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_COPY </font><font color="#ff00ff">2178</font>
|
||||
|
||||
<font color="#0000ff">// Paste the contents of the clipboard into the document replacing the selection.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PASTE </font><font color="#ff00ff">2179</font>
|
||||
|
||||
<font color="#0000ff">// Clear the selection.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CLEAR </font><font color="#ff00ff">2180</font>
|
||||
|
||||
<font color="#0000ff">// Move caret down one line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEDOWN </font><font color="#ff00ff">2300</font>
|
||||
|
||||
<font color="#0000ff">// Move caret down one line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEDOWNEXTEND </font><font color="#ff00ff">2301</font>
|
||||
|
||||
<font color="#0000ff">// Move caret up one line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEUP </font><font color="#ff00ff">2302</font>
|
||||
|
||||
<font color="#0000ff">// Move caret up one line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEUPEXTEND </font><font color="#ff00ff">2303</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one character.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARLEFT </font><font color="#ff00ff">2304</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one character extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARLEFTEXTEND </font><font color="#ff00ff">2305</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one character.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARRIGHT </font><font color="#ff00ff">2306</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one character extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CHARRIGHTEXTEND </font><font color="#ff00ff">2307</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one word.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDLEFT </font><font color="#ff00ff">2308</font>
|
||||
|
||||
<font color="#0000ff">// Move caret left one word extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDLEFTEXTEND </font><font color="#ff00ff">2309</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one word.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDRIGHT </font><font color="#ff00ff">2310</font>
|
||||
|
||||
<font color="#0000ff">// Move caret right one word extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDRIGHTEXTEND </font><font color="#ff00ff">2311</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOME </font><font color="#ff00ff">2312</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOMEEXTEND </font><font color="#ff00ff">2313</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEEND </font><font color="#ff00ff">2314</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on line extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEENDEXTEND </font><font color="#ff00ff">2315</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position in document.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTSTART </font><font color="#ff00ff">2316</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position in document extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTSTARTEXTEND </font><font color="#ff00ff">2317</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position in document.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTEND </font><font color="#ff00ff">2318</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position in document extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DOCUMENTENDEXTEND </font><font color="#ff00ff">2319</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page up.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEUP </font><font color="#ff00ff">2320</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page up extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEUPEXTEND </font><font color="#ff00ff">2321</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page down.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEDOWN </font><font color="#ff00ff">2322</font>
|
||||
|
||||
<font color="#0000ff">// Move caret one page down extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_PAGEDOWNEXTEND </font><font color="#ff00ff">2323</font>
|
||||
|
||||
<font color="#0000ff">// Switch from insert to overtype mode or the reverse.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_EDITTOGGLEOVERTYPE </font><font color="#ff00ff">2324</font>
|
||||
|
||||
<font color="#0000ff">// Cancel any modes such as call tip or auto-completion list display.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_CANCEL </font><font color="#ff00ff">2325</font>
|
||||
|
||||
<font color="#0000ff">// Delete the selection or if no selection, the character before the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELETEBACK </font><font color="#ff00ff">2326</font>
|
||||
|
||||
<font color="#0000ff">// If selection is empty or all on one line replace the selection with a tab character.</font>
|
||||
<font color="#0000ff">// If more than one line selected, indent the lines.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_TAB </font><font color="#ff00ff">2327</font>
|
||||
|
||||
<font color="#0000ff">// Dedent the selected lines.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_BACKTAB </font><font color="#ff00ff">2328</font>
|
||||
|
||||
<font color="#0000ff">// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_NEWLINE </font><font color="#ff00ff">2329</font>
|
||||
|
||||
<font color="#0000ff">// Insert a Form Feed character.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_FORMFEED </font><font color="#ff00ff">2330</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to before first visible character on line.</font>
|
||||
<font color="#0000ff">// If already there move to first character on line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_VCHOME </font><font color="#ff00ff">2331</font>
|
||||
|
||||
<font color="#0000ff">// Like VCHome but extending selection to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_VCHOMEEXTEND </font><font color="#ff00ff">2332</font>
|
||||
|
||||
<font color="#0000ff">// Magnify the displayed text by increasing the sizes by 1 point.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_ZOOMIN </font><font color="#ff00ff">2333</font>
|
||||
|
||||
<font color="#0000ff">// Make the displayed text smaller by decreasing the sizes by 1 point.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_ZOOMOUT </font><font color="#ff00ff">2334</font>
|
||||
|
||||
<font color="#0000ff">// Delete the word to the left of the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELWORDLEFT </font><font color="#ff00ff">2335</font>
|
||||
|
||||
<font color="#0000ff">// Delete the word to the right of the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELWORDRIGHT </font><font color="#ff00ff">2336</font>
|
||||
|
||||
<font color="#0000ff">// Cut the line containing the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINECUT </font><font color="#ff00ff">2337</font>
|
||||
|
||||
<font color="#0000ff">// Delete the line containing the caret.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEDELETE </font><font color="#ff00ff">2338</font>
|
||||
|
||||
<font color="#0000ff">// Switch the current line with the previous.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINETRANSPOSE </font><font color="#ff00ff">2339</font>
|
||||
|
||||
<font color="#0000ff">// Duplicate the current line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEDUPLICATE </font><font color="#ff00ff">2404</font>
|
||||
|
||||
<font color="#0000ff">// Transform the selection to lower case.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LOWERCASE </font><font color="#ff00ff">2340</font>
|
||||
|
||||
<font color="#0000ff">// Transform the selection to upper case.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_UPPERCASE </font><font color="#ff00ff">2341</font>
|
||||
|
||||
<font color="#0000ff">// Scroll the document down, keeping the caret visible.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINESCROLLDOWN </font><font color="#ff00ff">2342</font>
|
||||
|
||||
<font color="#0000ff">// Scroll the document up, keeping the caret visible.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINESCROLLUP </font><font color="#ff00ff">2343</font>
|
||||
|
||||
<font color="#0000ff">// Delete the selection or if no selection, the character before the caret.</font>
|
||||
<font color="#0000ff">// Will not delete the character before at the start of a line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELETEBACKNOTLINE </font><font color="#ff00ff">2344</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on display line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOMEDISPLAY </font><font color="#ff00ff">2345</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on display line extending selection to</font>
|
||||
<font color="#0000ff">// new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_HOMEDISPLAYEXTEND </font><font color="#ff00ff">2346</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on display line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEENDDISPLAY </font><font color="#ff00ff">2347</font>
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on display line extending selection to new</font>
|
||||
<font color="#0000ff">// caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_LINEENDDISPLAYEXTEND </font><font color="#ff00ff">2348</font>
|
||||
|
||||
<font color="#0000ff">// Move to the previous change in capitalisation.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDPARTLEFT </font><font color="#ff00ff">2390</font>
|
||||
|
||||
<font color="#0000ff">// Move to the previous change in capitalisation extending selection</font>
|
||||
<font color="#0000ff">// to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDPARTLEFTEXTEND </font><font color="#ff00ff">2391</font>
|
||||
|
||||
<font color="#0000ff">// Move to the change next in capitalisation.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDPARTRIGHT </font><font color="#ff00ff">2392</font>
|
||||
|
||||
<font color="#0000ff">// Move to the next change in capitalisation extending selection</font>
|
||||
<font color="#0000ff">// to new caret position.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_WORDPARTRIGHTEXTEND </font><font color="#ff00ff">2393</font>
|
||||
|
||||
<font color="#0000ff">// Delete back from the current position to the start of the line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELLINELEFT </font><font color="#ff00ff">2395</font>
|
||||
|
||||
<font color="#0000ff">// Delete forwards from the current position to the end of the line.</font>
|
||||
<font color="#a020f0">#define wxSTC_CMD_DELLINERIGHT </font><font color="#ff00ff">2396</font>
|
||||
|
||||
|
||||
<font color="#0000ff">// END of generated section</font>
|
||||
<font color="#0000ff">//----------------------------------------------------------------------</font>
|
||||
|
||||
@@ -880,8 +1007,11 @@
|
||||
<font color="#2e8b57"><b>class</b></font> WordList;
|
||||
<font color="#2e8b57"><b>struct</b></font> SCNotification;
|
||||
|
||||
|
||||
<font color="#2e8b57"><b>extern</b></font> <font color="#2e8b57"><b>const</b></font> wxChar* wxSTCNameStr;
|
||||
<font color="#a020f0">#ifndef SWIG</font>
|
||||
<font color="#2e8b57"><b>extern</b></font> WXSTC_DECLSPEC <font color="#2e8b57"><b>const</b></font> wxChar* wxSTCNameStr;
|
||||
<font color="#2e8b57"><b>class</b></font> WXSTC_DECLSPEC wxStyledTextCtrl;
|
||||
<font color="#2e8b57"><b>class</b></font> WXSTC_DECLSPEC wxStyledTextEvent;
|
||||
<font color="#a020f0">#endif</font>
|
||||
|
||||
<font color="#0000ff">//----------------------------------------------------------------------</font>
|
||||
|
||||
@@ -1043,8 +1173,8 @@
|
||||
<font color="#0000ff">// Set the symbol used for a particular marker number,</font>
|
||||
<font color="#0000ff">// and optionally the fore and background colours.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> MarkerDefine(<font color="#2e8b57"><b>int</b></font> markerNumber, <font color="#2e8b57"><b>int</b></font> markerSymbol,
|
||||
<font color="#2e8b57"><b>const</b></font> wxColour& foreground = wxNullColour,
|
||||
<font color="#2e8b57"><b>const</b></font> wxColour& background = wxNullColour);
|
||||
<font color="#2e8b57"><b>const</b></font> wxColour& foreground = wxNullColour,
|
||||
<font color="#2e8b57"><b>const</b></font> wxColour& background = wxNullColour);
|
||||
|
||||
<font color="#0000ff">// Set the foreground colour used for a particular marker number.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> MarkerSetForeground(<font color="#2e8b57"><b>int</b></font> markerNumber, <font color="#2e8b57"><b>const</b></font> wxColour& fore);
|
||||
@@ -1070,6 +1200,9 @@
|
||||
<font color="#0000ff">// Find the previous line before lineStart that includes a marker in mask.</font>
|
||||
<font color="#2e8b57"><b>int</b></font> MarkerPrevious(<font color="#2e8b57"><b>int</b></font> lineStart, <font color="#2e8b57"><b>int</b></font> markerMask);
|
||||
|
||||
<font color="#0000ff">// Define a marker from a bitmap</font>
|
||||
<font color="#2e8b57"><b>void</b></font> MarkerDefineBitmap(<font color="#2e8b57"><b>int</b></font> markerNumber, <font color="#2e8b57"><b>const</b></font> wxBitmap& bmp);
|
||||
|
||||
<font color="#0000ff">// Set a margin to be either numeric or symbolic.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetMarginType(<font color="#2e8b57"><b>int</b></font> margin, <font color="#2e8b57"><b>int</b></font> marginType);
|
||||
|
||||
@@ -1291,6 +1424,19 @@
|
||||
<font color="#0000ff">// after the inserted text upon completion.</font>
|
||||
<font color="#2e8b57"><b>bool</b></font> AutoCompGetDropRestOfWord();
|
||||
|
||||
<font color="#0000ff">// Register an image for use in autocompletion lists.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> RegisterImage(<font color="#2e8b57"><b>int</b></font> type, <font color="#2e8b57"><b>const</b></font> wxBitmap& bmp);
|
||||
|
||||
<font color="#0000ff">// Clear all the registered images.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> ClearRegisteredImages();
|
||||
|
||||
<font color="#0000ff">// Retrieve the auto-completion list type-separator character.</font>
|
||||
<font color="#2e8b57"><b>int</b></font> AutoCompGetTypeSeparator();
|
||||
|
||||
<font color="#0000ff">// Change the type-separator character in the string setting up an auto-completion list.</font>
|
||||
<font color="#0000ff">// Default is '?' but can be changed if items contain '?'.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> AutoCompSetTypeSeparator(<font color="#2e8b57"><b>int</b></font> separatorCharacter);
|
||||
|
||||
<font color="#0000ff">// Set the number of spaces used for one level of indentation.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetIndent(<font color="#2e8b57"><b>int</b></font> indentSize);
|
||||
|
||||
@@ -1379,14 +1525,14 @@
|
||||
|
||||
<font color="#0000ff">// On Windows, will draw the document into a display context such as a printer.</font>
|
||||
<font color="#2e8b57"><b>int</b></font> FormatRange(<font color="#2e8b57"><b>bool</b></font> doDraw,
|
||||
<font color="#2e8b57"><b>int</b></font> startPos,
|
||||
<font color="#2e8b57"><b>int</b></font> endPos,
|
||||
wxDC* draw,
|
||||
wxDC* target, <font color="#0000ff">// Why does it use two? Can they be the same?</font>
|
||||
wxRect renderRect,
|
||||
wxRect pageRect);
|
||||
<font color="#2e8b57"><b>int</b></font> startPos,
|
||||
<font color="#2e8b57"><b>int</b></font> endPos,
|
||||
wxDC* draw,
|
||||
wxDC* target, <font color="#0000ff">// Why does it use two? Can they be the same?</font>
|
||||
wxRect renderRect,
|
||||
wxRect pageRect);
|
||||
|
||||
<font color="#0000ff">// Retrieve the line at the top of the display.</font>
|
||||
<font color="#0000ff">// Retrieve the display line at the top of the display.</font>
|
||||
<font color="#2e8b57"><b>int</b></font> GetFirstVisibleLine();
|
||||
|
||||
<font color="#0000ff">// Retrieve the contents of a line.</font>
|
||||
@@ -1582,7 +1728,7 @@
|
||||
<font color="#0000ff">// Ensure a particular line is visible by expanding any header line hiding it.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> EnsureVisible(<font color="#2e8b57"><b>int</b></font> line);
|
||||
|
||||
<font color="#0000ff">// Set some debugging options for folding.</font>
|
||||
<font color="#0000ff">// Set some style options for folding.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetFoldFlags(<font color="#2e8b57"><b>int</b></font> flags);
|
||||
|
||||
<font color="#0000ff">// Ensure a particular line is visible by expanding any header line hiding it.</font>
|
||||
@@ -1648,17 +1794,51 @@
|
||||
<font color="#0000ff">// Retrieve the height of a particular line of text in pixels.</font>
|
||||
<font color="#2e8b57"><b>int</b></font> TextHeight(<font color="#2e8b57"><b>int</b></font> line);
|
||||
|
||||
<font color="#0000ff">// Show or hide the vertical scroll bar.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetUseVerticalScrollBar(<font color="#2e8b57"><b>bool</b></font> show);
|
||||
|
||||
<font color="#0000ff">// Is the vertical scroll bar visible?</font>
|
||||
<font color="#2e8b57"><b>bool</b></font> GetUseVerticalScrollBar();
|
||||
|
||||
<font color="#0000ff">// Append a string to the end of the document without changing the selection.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> AppendText(<font color="#2e8b57"><b>int</b></font> length, <font color="#2e8b57"><b>const</b></font> wxString& text);
|
||||
|
||||
<font color="#0000ff">// Is drawing done in two phases with backgrounds drawn before foregrounds?</font>
|
||||
<font color="#2e8b57"><b>bool</b></font> GetTwoPhaseDraw();
|
||||
|
||||
<font color="#0000ff">// In twoPhaseDraw mode, drawing is performed in two phases, first the background</font>
|
||||
<font color="#0000ff">// and then the foreground. This avoids chopping off characters that overlap the next run.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetTwoPhaseDraw(<font color="#2e8b57"><b>bool</b></font> twoPhase);
|
||||
|
||||
<font color="#0000ff">// Make the target range start and end be the same as the selection range start and end.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> TargetFromSelection();
|
||||
|
||||
<font color="#0000ff">// Join the lines in the target.</font>
|
||||
<font color="#0000ff">// This is an experimental feature and may be changed or removed.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> LinesJoin();
|
||||
|
||||
<font color="#0000ff">// Split the lines in the target into lines that are less wide than pixelWidth</font>
|
||||
<font color="#0000ff">// where possible.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> LinesSplit(<font color="#2e8b57"><b>int</b></font> pixelWidth);
|
||||
|
||||
<font color="#0000ff">// Set the colours used as a chequerboard pattern in the fold margin</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetFoldMarginColour(<font color="#2e8b57"><b>bool</b></font> useSetting, <font color="#2e8b57"><b>const</b></font> wxColour& back);
|
||||
<font color="#2e8b57"><b>void</b></font> SetFoldMarginHiColour(<font color="#2e8b57"><b>bool</b></font> useSetting, <font color="#2e8b57"><b>const</b></font> wxColour& fore);
|
||||
|
||||
<font color="#0000ff">// Duplicate the current line.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> LineDuplicate();
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on display line.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> HomeDisplay();
|
||||
|
||||
<font color="#0000ff">// Move caret to first position on display line extending selection to </font>
|
||||
<font color="#0000ff">// Move caret to first position on display line extending selection to</font>
|
||||
<font color="#0000ff">// new caret position.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> HomeDisplayExtend();
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on display line.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> LineEndDisplay();
|
||||
|
||||
<font color="#0000ff">// Move caret to last position on display line extending selection to new </font>
|
||||
<font color="#0000ff">// Move caret to last position on display line extending selection to new</font>
|
||||
<font color="#0000ff">// caret position.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> LineEndDisplayExtend();
|
||||
|
||||
@@ -1812,6 +1992,9 @@
|
||||
<font color="#2e8b57"><b>void</b></font> SetXOffset(<font color="#2e8b57"><b>int</b></font> newOffset);
|
||||
<font color="#2e8b57"><b>int</b></font> GetXOffset();
|
||||
|
||||
<font color="#0000ff">// Set the last x chosen value to be the caret x position</font>
|
||||
<font color="#2e8b57"><b>void</b></font> ChooseCaretX();
|
||||
|
||||
<font color="#0000ff">// Set the way the caret is kept visible when going sideway.</font>
|
||||
<font color="#0000ff">// The exclusion zone is given in pixels.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetXCaretPolicy(<font color="#2e8b57"><b>int</b></font> caretPolicy, <font color="#2e8b57"><b>int</b></font> caretSlop);
|
||||
@@ -1820,6 +2003,12 @@
|
||||
<font color="#0000ff">// The exclusion zone is given in lines.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetYCaretPolicy(<font color="#2e8b57"><b>int</b></font> caretPolicy, <font color="#2e8b57"><b>int</b></font> caretSlop);
|
||||
|
||||
<font color="#0000ff">// Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).</font>
|
||||
<font color="#2e8b57"><b>void</b></font> SetPrintWrapMode(<font color="#2e8b57"><b>int</b></font> mode);
|
||||
|
||||
<font color="#0000ff">// Is printing line wrapped.</font>
|
||||
<font color="#2e8b57"><b>int</b></font> GetPrintWrapMode();
|
||||
|
||||
<font color="#0000ff">// Start notifying the container of all key presses and commands.</font>
|
||||
<font color="#2e8b57"><b>void</b></font> StartRecord();
|
||||
|
||||
@@ -1940,6 +2129,7 @@
|
||||
<font color="#2e8b57"><b>void</b></font> OnMouseMove(wxMouseEvent& evt);
|
||||
<font color="#2e8b57"><b>void</b></font> OnMouseLeftUp(wxMouseEvent& evt);
|
||||
<font color="#2e8b57"><b>void</b></font> OnMouseRightUp(wxMouseEvent& evt);
|
||||
<font color="#2e8b57"><b>void</b></font> OnMouseMiddleUp(wxMouseEvent& evt);
|
||||
<font color="#2e8b57"><b>void</b></font> OnContextMenu(wxContextMenuEvent& evt);
|
||||
<font color="#2e8b57"><b>void</b></font> OnMouseWheel(wxMouseEvent& evt);
|
||||
<font color="#2e8b57"><b>void</b></font> OnChar(wxKeyEvent& evt);
|
||||
@@ -1975,7 +2165,7 @@
|
||||
|
||||
<font color="#0000ff">//----------------------------------------------------------------------</font>
|
||||
|
||||
<font color="#0000ff">// SWIG can't handle "#if" type of conditionals, onlu "#ifdef"</font>
|
||||
<font color="#0000ff">// SWIG can't handle "#if" type of conditionals, only "#ifdef"</font>
|
||||
<font color="#a020f0">#ifdef SWIG</font>
|
||||
<font color="#a020f0">#define STC_USE_DND </font><font color="#ff00ff">1</font>
|
||||
<font color="#a020f0">#else</font>
|
||||
|
290
wxPython/demo/data/wxPackage.html
Normal file
290
wxPython/demo/data/wxPackage.html
Normal file
@@ -0,0 +1,290 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<meta name="generator" content="Docutils 0.2.8: http://docutils.sourceforge.net/" />
|
||||
<title>The wxPython wx Package</title>
|
||||
<meta name="author" content="Patrick K. O'Brien" />
|
||||
<meta name="organization" content="Orbtech" />
|
||||
<meta name="date" content="2003-05-08" />
|
||||
<link rel="stylesheet" href="default.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="the-wxpython-wx-package">
|
||||
<h1 class="title">The wxPython wx Package</h1>
|
||||
<h2 class="subtitle" id="or-how-to-survive-the-new-wx-namespace-changes">Or, how to survive the new wx namespace changes.</h2>
|
||||
<table class="docinfo" frame="void" rules="none">
|
||||
<col class="docinfo-name" />
|
||||
<col class="docinfo-content" />
|
||||
<tbody valign="top">
|
||||
<tr><th class="docinfo-name">Author:</th>
|
||||
<td>Patrick K. O'Brien</td></tr>
|
||||
<tr><th class="docinfo-name">Contact:</th>
|
||||
<td><a class="first last reference" href="mailto:pobrien@orbtech.com">pobrien@orbtech.com</a></td></tr>
|
||||
<tr><th class="docinfo-name">Organization:</th>
|
||||
<td><a class="first last reference" href="http://www.orbtech.com/">Orbtech</a></td></tr>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>2003-05-08</td></tr>
|
||||
<tr><th class="docinfo-name">Revision:</th>
|
||||
<td>1.1.2.4</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="contents topic" id="contents">
|
||||
<p class="topic-title"><a name="contents">Contents</a></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="#introduction" id="id1" name="id1">Introduction</a></li>
|
||||
<li><a class="reference" href="#why-change-anything" id="id2" name="id2">Why change anything?</a></li>
|
||||
<li><a class="reference" href="#what-does-the-new-wx-package-do" id="id3" name="id3">What does the new wx package do?</a></li>
|
||||
<li><a class="reference" href="#will-any-of-this-effect-my-existing-code" id="id4" name="id4">Will any of this effect my existing code?</a></li>
|
||||
<li><a class="reference" href="#how-does-the-new-wx-package-work" id="id5" name="id5">How does the new wx package work?</a></li>
|
||||
<li><a class="reference" href="#what-about-all-the-other-modules-like-grid-html-and-stc" id="id6" name="id6">What about all the other modules, like grid, html, and stc?</a></li>
|
||||
<li><a class="reference" href="#how-do-i-use-this-new-wx-package" id="id7" name="id7">How do I use this new wx package?</a></li>
|
||||
<li><a class="reference" href="#what-are-the-issues-with-converting-old-code-to-use-the-new-wx-package" id="id8" name="id8">What are the issues with converting old code to use the new wx package?</a></li>
|
||||
<li><a class="reference" href="#where-can-i-find-example-programs-using-the-new-wx-syntax" id="id9" name="id9">Where can I find example programs using the new wx syntax?</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="introduction">
|
||||
<h1><a class="toc-backref" href="#id1" name="introduction">Introduction</a></h1>
|
||||
<p>Big things sometimes come in small packages. This is certainly true
|
||||
of the new wx package, which is being introduced in wxPython 2.4.1 as
|
||||
a way to allow the "wx" prefix to be dropped from the names of all
|
||||
wxPython classes, functions, and constants. This document should
|
||||
answer all the questions you might have concerning the new wx package.
|
||||
If not, feel free to contact the author. I hope you like the new wx
|
||||
package as much as I do.</p>
|
||||
</div>
|
||||
<div class="section" id="why-change-anything">
|
||||
<h1><a class="toc-backref" href="#id2" name="why-change-anything">Why change anything?</a></h1>
|
||||
<p>This change is being made for a couple of reasons. The first reason
|
||||
is to discourage the use of <tt class="literal"><span class="pre">import</span> <span class="pre">*</span></tt>, which is a dangerous
|
||||
technique that can create name conflicts and bloated namespaces.</p>
|
||||
<p>The second reason is to remove what some perceive to be a "wart." For
|
||||
example, the following code is rather ugly in that the "wx" prefix on
|
||||
the wxFrame class name is no longer useful when you're using the wx
|
||||
module prefix:</p>
|
||||
<pre class="literal-block">
|
||||
from wxPython import wx
|
||||
|
||||
class Frame(wx.wxFrame)
|
||||
</pre>
|
||||
<p>The new wx package allows you to write code like this, instead:</p>
|
||||
<pre class="literal-block">
|
||||
import wx
|
||||
|
||||
class Frame(wx.Frame)
|
||||
</pre>
|
||||
<p>The third reason is that the wxWindows project intends to do the same
|
||||
thing (implement a new wx namespace and drop the "wx" prefix) and we
|
||||
want wxPython to lead the way.</p>
|
||||
</div>
|
||||
<div class="section" id="what-does-the-new-wx-package-do">
|
||||
<h1><a class="toc-backref" href="#id3" name="what-does-the-new-wx-package-do">What does the new wx package do?</a></h1>
|
||||
<p>As a way of getting to this new syntax as quickly as possible, the
|
||||
code in this new wx package was created. What it does is alter the
|
||||
existing wx namespace dynamically. By making the changes on-the-fly
|
||||
at runtime, we can try out the new syntax before any permanent changes
|
||||
are made to the underlying class library. The downside of making
|
||||
these changes at runtime is that there is a slight delay when you
|
||||
<tt class="literal"><span class="pre">import</span> <span class="pre">wx</span></tt>; the upside is that you can start using the new syntax
|
||||
now.</p>
|
||||
</div>
|
||||
<div class="section" id="will-any-of-this-effect-my-existing-code">
|
||||
<h1><a class="toc-backref" href="#id4" name="will-any-of-this-effect-my-existing-code">Will any of this effect my existing code?</a></h1>
|
||||
<p>No. Your existing code will continue to work and be supported for
|
||||
some time. It will be up to you to decide when to switch to the new
|
||||
syntax. But all new documentation and code examples will use the new
|
||||
syntax. So don't wait too long. You wouldn't want anyone calling you
|
||||
old-fashioned, would you?</p>
|
||||
</div>
|
||||
<div class="section" id="how-does-the-new-wx-package-work">
|
||||
<h1><a class="toc-backref" href="#id5" name="how-does-the-new-wx-package-work">How does the new wx package work?</a></h1>
|
||||
<p>It's pretty simple, and pretty clever. The wx directory contains an
|
||||
<tt class="literal"><span class="pre">__init__.py</span></tt> file, making it a Python package. (In contrast, the
|
||||
old wxPython.wx module is a module, not a package.) When you <tt class="literal"><span class="pre">import</span>
|
||||
<span class="pre">wx</span></tt> the code in the <tt class="literal"><span class="pre">__init__.py</span></tt> file is executed, and that's
|
||||
where all the magic takes place. Let's take a look at the code inside
|
||||
the <tt class="literal"><span class="pre">__init__.py</span></tt> file:</p>
|
||||
<pre class="literal-block">
|
||||
"""wx package
|
||||
|
||||
Provides a way to drop the wx prefix from wxPython objects."""
|
||||
|
||||
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
|
||||
__cvsid__ = "$Id$"
|
||||
__revision__ = "$Revision$"[11:-2]
|
||||
|
||||
from wxPython import wx
|
||||
|
||||
import types
|
||||
|
||||
d_new = globals()
|
||||
d_old = wx.__dict__
|
||||
|
||||
for old, obj in d_old.items():
|
||||
if type(obj) is types.ModuleType or old.startswith('_'):
|
||||
# Skip modules and private names.
|
||||
continue
|
||||
new = old
|
||||
if old.startswith('EVT_'):
|
||||
# Leave name unmodified; add to the new wx namespace.
|
||||
d_new[new] = obj
|
||||
elif old.startswith('wxEVT_'):
|
||||
# Leave name unmodified; add to the new wx namespace.
|
||||
d_new[new] = obj
|
||||
else:
|
||||
if old.startswith('wx'):
|
||||
# Remove the 'wx' prefix.
|
||||
new = old[2:]
|
||||
# Add to the new wx package namespace.
|
||||
d_new[new] = obj
|
||||
|
||||
del d_new
|
||||
del d_old
|
||||
del new
|
||||
del obj
|
||||
del old
|
||||
del types
|
||||
|
||||
del wx
|
||||
|
||||
</pre>
|
||||
<p>Namespaces in Python are implemented as dictionaries. The dictionary
|
||||
used to create the wx package's namespace is accessible using the
|
||||
<tt class="literal"><span class="pre">globals()</span></tt> function. The dictionary used to create the old
|
||||
wxPython.wx module's namespace is <tt class="literal"><span class="pre">wx.__dict__</span></tt>. Once we have these
|
||||
two dictionaries, it's a simple matter of iterating through one,
|
||||
changing the names, adding the renamed object to the other dictionary,
|
||||
and cleaning up a few local variables and imported modules. Voila!</p>
|
||||
</div>
|
||||
<div class="section" id="what-about-all-the-other-modules-like-grid-html-and-stc">
|
||||
<h1><a class="toc-backref" href="#id6" name="what-about-all-the-other-modules-like-grid-html-and-stc">What about all the other modules, like grid, html, and stc?</a></h1>
|
||||
<p>There's more to wxPython than just the wx namespace. And we've got
|
||||
those extra modules covered as well. For each of those modules (as
|
||||
well as the lib package) we've got matching modules in the new wx
|
||||
package. Let's take a look at a few of them.</p>
|
||||
<p>Here is <tt class="literal"><span class="pre">html.py</span></tt>:</p>
|
||||
<pre class="literal-block">
|
||||
"""Provides a way to drop the wx prefix from wxPython objects."""
|
||||
|
||||
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
|
||||
__cvsid__ = "$Id$"
|
||||
__revision__ = "$Revision$"[11:-2]
|
||||
|
||||
import wx
|
||||
from wx import prefix
|
||||
|
||||
from wxPython import html
|
||||
prefix.rename(d_new=globals(), d_old=html.__dict__)
|
||||
del html
|
||||
|
||||
del prefix
|
||||
del wx
|
||||
|
||||
</pre>
|
||||
<p>And here is <tt class="literal"><span class="pre">lib/dialogs.py</span></tt>:</p>
|
||||
<pre class="literal-block">
|
||||
"""Provides a way to drop the wx prefix from wxPython objects."""
|
||||
|
||||
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
|
||||
__cvsid__ = "$Id$"
|
||||
__revision__ = "$Revision$"[11:-2]
|
||||
|
||||
import wx
|
||||
from wx import prefix
|
||||
|
||||
from wxPython.lib import dialogs
|
||||
prefix.rename(d_new=globals(), d_old=dialogs.__dict__)
|
||||
del dialogs
|
||||
|
||||
del prefix
|
||||
del wx
|
||||
|
||||
</pre>
|
||||
<p>As you can see, they both rely on the <tt class="literal"><span class="pre">prefix.rename()</span></tt> function
|
||||
defined in <tt class="literal"><span class="pre">prefix.py</span></tt>:</p>
|
||||
<pre class="literal-block">
|
||||
"""Renaming utility.
|
||||
|
||||
Provides a way to drop the wx prefix from wxPython objects."""
|
||||
|
||||
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
|
||||
__cvsid__ = "$Id$"
|
||||
__revision__ = "$Revision$"[11:-2]
|
||||
|
||||
import types
|
||||
|
||||
def rename(d_new, d_old):
|
||||
for old, obj in d_old.items():
|
||||
if type(obj) is types.ModuleType or old.startswith('_'):
|
||||
# Skip modules and private names.
|
||||
continue
|
||||
## mod = d_old['__name__']
|
||||
## if hasattr(obj, '__module__') and not obj.__module__.startswith(mod):
|
||||
## # Skip objects imported from other modules, except those
|
||||
## # related to the current module, such as stc_.
|
||||
## continue
|
||||
new = old
|
||||
if old.startswith('EVT_') or old.startswith('wxEVT_'):
|
||||
# Leave these names unmodified.
|
||||
pass
|
||||
elif old.startswith('wx'):
|
||||
new = old[2:]
|
||||
if new:
|
||||
d_new[new] = d_old[old]
|
||||
|
||||
</pre>
|
||||
<p>Again, the technique is very similar to the one used by the wx
|
||||
package.</p>
|
||||
</div>
|
||||
<div class="section" id="how-do-i-use-this-new-wx-package">
|
||||
<h1><a class="toc-backref" href="#id7" name="how-do-i-use-this-new-wx-package">How do I use this new wx package?</a></h1>
|
||||
<p>The wx package is automatically created when you install wxPython
|
||||
version 2.4.1 or higher. So all you have to do is:</p>
|
||||
<pre class="literal-block">
|
||||
import wx
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="what-are-the-issues-with-converting-old-code-to-use-the-new-wx-package">
|
||||
<h1><a class="toc-backref" href="#id8" name="what-are-the-issues-with-converting-old-code-to-use-the-new-wx-package">What are the issues with converting old code to use the new wx package?</a></h1>
|
||||
<p>Obviously, you need to change your import statements from:</p>
|
||||
<pre class="literal-block">
|
||||
from wxPython import wx
|
||||
</pre>
|
||||
<p>or:</p>
|
||||
<pre class="literal-block">
|
||||
from wxPython.wx import *
|
||||
</pre>
|
||||
<p>to:</p>
|
||||
<pre class="literal-block">
|
||||
import wx
|
||||
</pre>
|
||||
<p>Then you need to refer to wx attributes without a "wx" prefix, such
|
||||
as:</p>
|
||||
<pre class="literal-block">
|
||||
class MyFrame(wx.Frame):
|
||||
</pre>
|
||||
<p>In most cases, existing code can be modified with a simple search and
|
||||
replace.</p>
|
||||
<p>One extra issue you might run into when converting existing code is
|
||||
that the wx.__version__ attribute is no longer available, since the
|
||||
new wx namespace doesn't include any private attributes from the old
|
||||
wxPython.wx namespace. The solution is to use the wx.VERSION_STRING
|
||||
attribute, which was introduced in wxPython 2.4.1.</p>
|
||||
</div>
|
||||
<div class="section" id="where-can-i-find-example-programs-using-the-new-wx-syntax">
|
||||
<h1><a class="toc-backref" href="#id9" name="where-can-i-find-example-programs-using-the-new-wx-syntax">Where can I find example programs using the new wx syntax?</a></h1>
|
||||
<p>Example programs are included in the wxPython/samples/wx_examples
|
||||
directory, and are documented in the <a class="reference" href="wxPythonExamples.html">wxPythonExamples</a> documentation
|
||||
file. Also, all the code in the py package uses the new wx syntax.
|
||||
You can learn more about these in the <a class="reference" href="PyManual.html">PyManual</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="footer"/>
|
||||
<div class="footer">
|
||||
<a class="reference" href="wxPackage.txt">View document source</a>.
|
||||
Generated on: 2003-06-04 18:07 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -9,48 +9,48 @@ in Python. This is not part of the demo framework.
|
||||
"""
|
||||
|
||||
|
||||
from wxPython.wx import *
|
||||
import wx # This module uses the new wx namespace
|
||||
import time
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
class MyFrame(wx.Frame):
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, id, title,
|
||||
wxPoint(100, 100), wxSize(160, 150))
|
||||
wx.Frame.__init__(self, parent, id, title,
|
||||
wx.Point(100, 100), wx.Size(160, 150))
|
||||
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_MOVE(self, self.OnMove)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
wx.EVT_SIZE(self, self.OnSize)
|
||||
wx.EVT_MOVE(self, self.OnMove)
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
wx.EVT_IDLE(self, self.OnIdle)
|
||||
|
||||
self.count = 0
|
||||
|
||||
panel = wxPanel(self, -1)
|
||||
wxStaticText(panel, -1, "Size:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 4)), wxDefaultSize)
|
||||
wxStaticText(panel, -1, "Pos:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 16)), wxDefaultSize)
|
||||
panel = wx.Panel(self, -1)
|
||||
wx.StaticText(panel, -1, "Size:",
|
||||
wx.DLG_PNT(panel, wx.Point(4, 4)), wx.DefaultSize)
|
||||
wx.StaticText(panel, -1, "Pos:",
|
||||
wx.DLG_PNT(panel, wx.Point(4, 16)), wx.DefaultSize)
|
||||
|
||||
wxStaticText(panel, -1, "Idle:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 28)), wxDefaultSize)
|
||||
wx.StaticText(panel, -1, "Idle:",
|
||||
wx.DLG_PNT(panel, wx.Point(4, 28)), wx.DefaultSize)
|
||||
|
||||
self.sizeCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 4)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
self.sizeCtrl = wx.TextCtrl(panel, -1, "",
|
||||
wx.DLG_PNT(panel, wx.Point(24, 4)),
|
||||
wx.DLG_SZE(panel, wx.Size(36, -1)),
|
||||
wx.TE_READONLY)
|
||||
|
||||
self.posCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 16)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
self.posCtrl = wx.TextCtrl(panel, -1, "",
|
||||
wx.DLG_PNT(panel, wx.Point(24, 16)),
|
||||
wx.DLG_SZE(panel, wx.Size(36, -1)),
|
||||
wx.TE_READONLY)
|
||||
|
||||
self.idleCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 28)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
self.idleCtrl = wx.TextCtrl(panel, -1, "",
|
||||
wx.DLG_PNT(panel, wx.Point(24, 28)),
|
||||
wx.DLG_SZE(panel, wx.Size(36, -1)),
|
||||
wx.TE_READONLY)
|
||||
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
@@ -74,7 +74,7 @@ class MyFrame(wxFrame):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyApp(wxApp):
|
||||
class MyApp(wx.App):
|
||||
def MainLoop(self):
|
||||
# This outer loop determines when to exit the application, for
|
||||
# this example we let the main frame reset this flag when it
|
||||
|
@@ -60,6 +60,7 @@ command_lines = [
|
||||
"-a -u -n WizTest1 bmp_source/wiztest1.bmp images.py",
|
||||
"-a -u -n WizTest2 bmp_source/wiztest2.bmp images.py",
|
||||
|
||||
"-a -u -n Tux bmp_source/Tux.png images.py",
|
||||
|
||||
|
||||
" -u -c bmp_source/001.png throbImages.py",
|
||||
|
@@ -1,468 +0,0 @@
|
||||
"""Hangman.py, a simple wxPython game, inspired by the
|
||||
old bsd game by Ken Arnold.
|
||||
From the original man page:
|
||||
|
||||
In hangman, the computer picks a word from the on-line
|
||||
word list and you must try to guess it. The computer
|
||||
keeps track of which letters have been guessed and how
|
||||
many wrong guesses you have made on the screen in a
|
||||
graphic fashion.
|
||||
|
||||
That says it all, doesn't it?
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)"""
|
||||
|
||||
import random,re
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
|
||||
class WordFetcher:
|
||||
builtin_words = ' albatros banana electrometer eggshell'
|
||||
|
||||
def __init__(self, filename, min_length = 5):
|
||||
self.min_length = min_length
|
||||
print "Trying to open file %s" % (filename,)
|
||||
try:
|
||||
f = open(filename, "r")
|
||||
except:
|
||||
print "Couldn't open dictionary file %s, using builtins" % (filename,)
|
||||
self.words = self.builtin_words
|
||||
self.filename = None
|
||||
return
|
||||
self.words = f.read()
|
||||
self.filename = filename
|
||||
print "Got %d bytes." % (len(self.words),)
|
||||
|
||||
def SetMinLength(min_length):
|
||||
self.min_length = min_length
|
||||
|
||||
def Get(self):
|
||||
reg = re.compile('\s+([a-zA-Z]+)\s+')
|
||||
n = 50 # safety valve; maximum number of tries to find a suitable word
|
||||
while n:
|
||||
index = int(random.random()*len(self.words))
|
||||
m = reg.search(self.words[index:])
|
||||
if m and len(m.groups()[0]) >= self.min_length: break
|
||||
n = n - 1
|
||||
if n: return m.groups()[0].lower()
|
||||
return "error"
|
||||
|
||||
|
||||
|
||||
def stdprint(x):
|
||||
print x
|
||||
|
||||
|
||||
|
||||
class URLWordFetcher(WordFetcher):
|
||||
def __init__(self, url):
|
||||
self.OpenURL(url)
|
||||
WordFetcher.__init__(self, "hangman_dict.txt")
|
||||
|
||||
def logprint(self,x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(self, host, path=''):
|
||||
from httplib import HTTP
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
self.logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
self.logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
return f
|
||||
|
||||
def OpenURL(self,url):
|
||||
from htmllib import HTMLParser
|
||||
import formatter
|
||||
self.url = url
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = self.RetrieveAsFile(host,path)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('hangman_dict.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
|
||||
|
||||
|
||||
class HangmanWnd(wxWindow):
|
||||
def __init__(self, parent, id, pos=wxDefaultPosition, size=wxDefaultSize):
|
||||
wxWindow.__init__(self, parent, id, pos, size)
|
||||
self.SetBackgroundColour(wxNamedColour('white'))
|
||||
if wxPlatform == '__WXGTK__':
|
||||
self.font = wxFont(12, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
else:
|
||||
self.font = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
self.SetFocus()
|
||||
EVT_PAINT(self, self.OnPaint)
|
||||
|
||||
|
||||
def StartGame(self, word):
|
||||
self.word = word
|
||||
self.guess = []
|
||||
self.tries = 0
|
||||
self.misses = 0
|
||||
self.Draw()
|
||||
|
||||
def EndGame(self):
|
||||
self.misses = 7;
|
||||
self.guess = map(chr, range(ord('a'),ord('z')+1))
|
||||
self.Draw()
|
||||
|
||||
def HandleKey(self, key):
|
||||
self.message = ""
|
||||
if self.guess.count(key):
|
||||
self.message = 'Already guessed %s' % (key,)
|
||||
return 0
|
||||
self.guess.append(key)
|
||||
self.guess.sort()
|
||||
self.tries = self.tries+1
|
||||
if not key in self.word:
|
||||
self.misses = self.misses+1
|
||||
if self.misses == 7:
|
||||
self.EndGame()
|
||||
return 1
|
||||
has_won = 1
|
||||
for letter in self.word:
|
||||
if not self.guess.count(letter):
|
||||
has_won = 0
|
||||
break
|
||||
if has_won:
|
||||
self.Draw()
|
||||
return 2
|
||||
self.Draw()
|
||||
return 0
|
||||
|
||||
def Draw(self, dc = None):
|
||||
if not dc:
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.font)
|
||||
dc.Clear()
|
||||
(x,y) = self.GetSizeTuple()
|
||||
x1 = x-200; y1 = 20
|
||||
for letter in self.word:
|
||||
if self.guess.count(letter):
|
||||
dc.DrawText(letter, x1, y1)
|
||||
else:
|
||||
dc.DrawText('.', x1, y1)
|
||||
x1 = x1 + 10
|
||||
x1 = x-200
|
||||
dc.DrawText("tries %d misses %d" % (self.tries,self.misses),x1,50)
|
||||
guesses = ""
|
||||
for letter in self.guess:
|
||||
guesses = guesses + letter
|
||||
dc.DrawText("guessed:", x1, 70)
|
||||
dc.DrawText(guesses[:13], x1+80, 70)
|
||||
dc.DrawText(guesses[13:], x1+80, 90)
|
||||
dc.SetUserScale(x/1000.0, y/1000.0)
|
||||
self.DrawVictim(dc)
|
||||
|
||||
def DrawVictim(self, dc):
|
||||
dc.SetPen(wxPen(wxNamedColour('black'), 20))
|
||||
dc.DrawLines([(10, 980), (10,900), (700,900), (700,940), (720,940),
|
||||
(720,980), (900,980)])
|
||||
dc.DrawLines([(100,900), (100, 100), (300,100)])
|
||||
dc.DrawLine(100,200,200,100)
|
||||
if ( self.misses == 0 ): return
|
||||
dc.SetPen(wxPen(wxNamedColour('blue'), 10))
|
||||
dc.DrawLine(300,100,300,200)
|
||||
if ( self.misses == 1 ): return
|
||||
dc.DrawEllipse(250,200,100,100)
|
||||
if ( self.misses == 2 ): return
|
||||
dc.DrawLine(300,300,300,600)
|
||||
if ( self.misses == 3) : return
|
||||
dc.DrawLine(300,300,250,550)
|
||||
if ( self.misses == 4) : return
|
||||
dc.DrawLine(300,300,350,550)
|
||||
if ( self.misses == 5) : return
|
||||
dc.DrawLine(300,600,350,850)
|
||||
if ( self.misses == 6) : return
|
||||
dc.DrawLine(300,600,250,850)
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
self.Draw(dc)
|
||||
|
||||
|
||||
|
||||
class HangmanDemo(HangmanWnd):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
HangmanWnd.__init__(self, parent, id, pos, size)
|
||||
self.StartGame("dummy")
|
||||
self.start_new = 1
|
||||
self.wf = wf
|
||||
self.delay = 500
|
||||
self.timer = self.PlayTimer(self.MakeMove)
|
||||
|
||||
def MakeMove(self):
|
||||
self.timer.Stop()
|
||||
if self.start_new:
|
||||
self.StartGame(self.wf.Get())
|
||||
self.start_new = 0
|
||||
self.left = list('aaaabcdeeeeefghiiiiijklmnnnoooopqrssssttttuuuuvwxyz')
|
||||
else:
|
||||
key = self.left[int(random.random()*len(self.left))]
|
||||
while self.left.count(key): self.left.remove(key)
|
||||
self.start_new = self.HandleKey(key)
|
||||
self.timer.Start(self.delay)
|
||||
|
||||
def Stop(self):
|
||||
self.timer.Stop()
|
||||
|
||||
class PlayTimer(wxTimer):
|
||||
def __init__(self,func):
|
||||
wxTimer.__init__(self)
|
||||
self.func = func
|
||||
self.Start(1000)
|
||||
|
||||
def Notify(self):
|
||||
apply(self.func, ())
|
||||
|
||||
|
||||
|
||||
class HangmanDemoFrame(wxFrame):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
wxFrame.__init__(self, parent, id, "Hangman demo", pos, size)
|
||||
self.demo = HangmanDemo(wf, self, -1, wxDefaultPosition, wxDefaultSize)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.demo.timer.Stop()
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class AboutBox(wxDialog):
|
||||
def __init__(self, parent,wf):
|
||||
wxDialog.__init__(self, parent, -1, "About Hangman", wxDefaultPosition, wxSize(350,450))
|
||||
self.wnd = HangmanDemo(wf, self, -1, wxPoint(1,1), wxSize(350,150))
|
||||
self.static = wxStaticText(self, -1, __doc__, wxPoint(1,160), wxSize(350, 250))
|
||||
self.button = wxButton(self, 2001, "OK", wxPoint(150,420), wxSize(50,-1))
|
||||
EVT_BUTTON(self, 2001, self.OnOK)
|
||||
|
||||
def OnOK(self, event):
|
||||
self.wnd.Stop()
|
||||
self.EndModal(wxID_OK)
|
||||
|
||||
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self, parent, wf):
|
||||
self.wf = wf
|
||||
wxFrame.__init__(self, parent, -1, "hangman", wxDefaultPosition, wxSize(400,300))
|
||||
self.wnd = HangmanWnd(self, -1)
|
||||
menu = wxMenu()
|
||||
menu.Append(1001, "New")
|
||||
menu.Append(1002, "End")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1003, "Reset")
|
||||
menu.Append(1004, "Demo...")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1005, "Exit")
|
||||
menubar = wxMenuBar()
|
||||
menubar.Append(menu, "Game")
|
||||
menu = wxMenu()
|
||||
#menu.Append(1010, "Internal", "Use internal dictionary", True)
|
||||
menu.Append(1011, "ASCII File...")
|
||||
urls = [ 'wxPython home', 'http://wxPython.org/',
|
||||
'slashdot.org', 'http://slashdot.org/',
|
||||
'cnn.com', 'http://cnn.com',
|
||||
'The New York Times', 'http://www.nytimes.com',
|
||||
'De Volkskrant', 'http://www.volkskrant.nl/frameless/25000006.html',
|
||||
'Gnu GPL', 'http://www.fsf.org/copyleft/gpl.html',
|
||||
'Bijbel: Genesis', 'http://www.coas.com/bijbel/gn1.htm']
|
||||
urlmenu = wxMenu()
|
||||
for item in range(0,len(urls),2):
|
||||
urlmenu.Append(1020+item/2, urls[item], urls[item+1])
|
||||
urlmenu.Append(1080, 'Other...', 'Enter an URL')
|
||||
menu.AppendMenu(1012, 'URL', urlmenu, 'Use a webpage')
|
||||
menu.Append(1013, 'Dump', 'Write contents to stdout')
|
||||
menubar.Append(menu, "Dictionary")
|
||||
self.urls = urls
|
||||
self.urloffset = 1020
|
||||
menu = wxMenu()
|
||||
menu.Append(1090, "About...")
|
||||
menubar.Append(menu, "Help")
|
||||
self.SetMenuBar(menubar)
|
||||
self.CreateStatusBar(2)
|
||||
EVT_MENU(self, 1001, self.OnGameNew)
|
||||
EVT_MENU(self, 1002, self.OnGameEnd)
|
||||
EVT_MENU(self, 1003, self.OnGameReset)
|
||||
EVT_MENU(self, 1004, self.OnGameDemo)
|
||||
EVT_MENU(self, 1005, self.OnWindowClose)
|
||||
EVT_MENU(self, 1011, self.OnDictFile)
|
||||
EVT_MENU_RANGE(self, 1020, 1020+len(urls)/2, self.OnDictURL)
|
||||
EVT_MENU(self, 1080, self.OnDictURLSel)
|
||||
EVT_MENU(self, 1013, self.OnDictDump)
|
||||
EVT_MENU(self, 1090, self.OnHelpAbout)
|
||||
EVT_CHAR(self.wnd, self.OnChar)
|
||||
self.OnGameReset()
|
||||
|
||||
def OnGameNew(self, event):
|
||||
word = self.wf.Get()
|
||||
self.in_progress = 1
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.StartGame(word)
|
||||
|
||||
def OnGameEnd(self, event):
|
||||
self.UpdateAverages(0)
|
||||
self.in_progress = 0
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.EndGame()
|
||||
|
||||
def OnGameReset(self, event=None):
|
||||
self.played = 0
|
||||
self.won = 0
|
||||
self.history = []
|
||||
self.average = 0.0
|
||||
self.OnGameNew(None)
|
||||
|
||||
def OnGameDemo(self, event):
|
||||
frame = HangmanDemoFrame(self.wf, self, -1, wxDefaultPosition, self.GetSize())
|
||||
frame.Show(True)
|
||||
|
||||
def OnDictFile(self, event):
|
||||
fd = wxFileDialog(self)
|
||||
if (self.wf.filename):
|
||||
fd.SetFilename(self.wf.filename)
|
||||
if fd.ShowModal() == wxID_OK:
|
||||
file = fd.GetPath()
|
||||
self.wf = WordFetcher(file)
|
||||
|
||||
def OnDictURL(self, event):
|
||||
item = (event.GetId() - self.urloffset)*2
|
||||
print "Trying to open %s at %s" % (self.urls[item], self.urls[item+1])
|
||||
self.wf = URLWordFetcher(self.urls[item+1])
|
||||
|
||||
def OnDictURLSel(self, event):
|
||||
msg = wxTextEntryDialog(self, "Enter the URL of the dictionary document", "Enter URL")
|
||||
if msg.ShowModal() == wxID_OK:
|
||||
url = msg.GetValue()
|
||||
self.wf = URLWordFetcher(url)
|
||||
def OnDictDump(self, event):
|
||||
print self.wf.words
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
about = AboutBox(self, self.wf)
|
||||
about.ShowModal()
|
||||
about.wnd.Stop() # that damn timer won't stop!
|
||||
|
||||
def UpdateAverages(self, has_won):
|
||||
if has_won:
|
||||
self.won = self.won + 1
|
||||
self.played = self.played+1
|
||||
self.history.append(self.wnd.misses) # ugly
|
||||
total = 0.0
|
||||
for m in self.history:
|
||||
total = total + m
|
||||
self.average = float(total/len(self.history))
|
||||
|
||||
def OnChar(self, event):
|
||||
if not self.in_progress:
|
||||
#print "new"
|
||||
self.OnGameNew(None)
|
||||
return
|
||||
key = event.KeyCode();
|
||||
#print key
|
||||
if key >= ord('A') and key <= ord('Z'):
|
||||
key = key + ord('a') - ord('A')
|
||||
key = chr(key)
|
||||
if key < 'a' or key > 'z':
|
||||
event.Skip()
|
||||
return
|
||||
res = self.wnd.HandleKey(key)
|
||||
if res == 0:
|
||||
self.SetStatusText(self.wnd.message)
|
||||
elif res == 1:
|
||||
self.UpdateAverages(0)
|
||||
self.SetStatusText("Too bad, you're dead!",0)
|
||||
self.in_progress = 0
|
||||
elif res == 2:
|
||||
self.in_progress = 0
|
||||
self.UpdateAverages(1)
|
||||
self.SetStatusText("Congratulations!",0)
|
||||
if self.played:
|
||||
percent = (100.*self.won)/self.played
|
||||
else:
|
||||
percent = 0.0
|
||||
self.SetStatusText("p %d, w %d (%g %%), av %g" % (self.played,self.won, percent, self.average),1)
|
||||
|
||||
def OnWindowClose(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
if wxPlatform == '__WXGTK__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
frame = MyFrame(None, wf)
|
||||
self.SetTopWindow(frame)
|
||||
frame.Show(True)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wxPlatform == '__WXGTK__' or wxPlatform == '__WXMOTIF__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
win = MyFrame(frame, wf)
|
||||
frame.otherWin = win
|
||||
win.Show(True)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -9,10 +9,10 @@ class MyFrame(wxFrame):
|
||||
wxFrame.__init__(self,None,-1,"Close me...",size=(300,100))
|
||||
menubar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
menu.Append(mID,"&Enable output","Display output frame")
|
||||
EVT_MENU(self,mID,output.EnableOutput)
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
menu.Append(mID,"&Disable output","Close output frame")
|
||||
EVT_MENU(self,mID,output.DisableOutput)
|
||||
menubar.Append(menu,"&Output")
|
||||
@@ -63,10 +63,10 @@ if __name__ == "__main__":
|
||||
## EVT_CLOSE(self,self.OnClose)
|
||||
## menubar = wxMenuBar()
|
||||
## menu = wxMenu()
|
||||
## mID = NewId()
|
||||
## mID = wxNewId()
|
||||
## menu.Append(mID,"&Enable output","Display output frame")
|
||||
## EVT_MENU(self,mID,output.EnableOutput)
|
||||
## mID = NewId()
|
||||
## mID = wxNewId()
|
||||
## menu.Append(mID,"&Disable output","Close output frame")
|
||||
## EVT_MENU(self,mID,output.DisableOutput)
|
||||
## menubar.Append(menu,"&Output")
|
||||
|
@@ -17,9 +17,9 @@ directory within its own frame window. Just specify the module name
|
||||
on the command line.
|
||||
"""
|
||||
|
||||
import wx # This module uses the new wx namespace
|
||||
|
||||
import sys, os
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
@@ -27,32 +27,34 @@ class Log:
|
||||
def WriteText(self, text):
|
||||
if text[-1:] == '\n':
|
||||
text = text[:-1]
|
||||
wxLogMessage(text)
|
||||
wx.LogMessage(text)
|
||||
write = WriteText
|
||||
|
||||
|
||||
class RunDemoApp(wxApp):
|
||||
class RunDemoApp(wx.App):
|
||||
def __init__(self, name, module):
|
||||
self.name = name
|
||||
self.demoModule = module
|
||||
wxApp.__init__(self, 0) ##wxPlatform == "__WXMAC__")
|
||||
wx.App.__init__(self, 0)
|
||||
|
||||
|
||||
def OnInit(self):
|
||||
wxInitAllImageHandlers()
|
||||
wxLog_SetActiveTarget(wxLogStderr())
|
||||
wx.InitAllImageHandlers()
|
||||
wx.Log_SetActiveTarget(wx.LogStderr())
|
||||
|
||||
frame = wxFrame(None, -1, "RunDemo: " + self.name, pos=(50,50), size=(0,0),
|
||||
style=wxNO_FULL_REPAINT_ON_RESIZE|wxDEFAULT_FRAME_STYLE)
|
||||
#self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
|
||||
|
||||
frame = wx.Frame(None, -1, "RunDemo: " + self.name, pos=(50,50), size=(0,0),
|
||||
style=wx.NO_FULL_REPAINT_ON_RESIZE|wx.DEFAULT_FRAME_STYLE)
|
||||
frame.CreateStatusBar()
|
||||
menuBar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menuBar = wx.MenuBar()
|
||||
menu = wx.Menu()
|
||||
menu.Append(101, "E&xit\tAlt-X", "Exit demo")
|
||||
EVT_MENU(self, 101, self.OnButton)
|
||||
wx.EVT_MENU(self, 101, self.OnButton)
|
||||
menuBar.Append(menu, "&File")
|
||||
frame.SetMenuBar(menuBar)
|
||||
frame.Show(True)
|
||||
EVT_CLOSE(frame, self.OnCloseFrame)
|
||||
wx.EVT_CLOSE(frame, self.OnCloseFrame)
|
||||
|
||||
win = self.demoModule.runTest(frame, frame, Log())
|
||||
|
||||
@@ -68,9 +70,9 @@ class RunDemoApp(wxApp):
|
||||
# otherwise the demo made its own frame, so just put a
|
||||
# button in this one
|
||||
if hasattr(frame, 'otherWin'):
|
||||
b = wxButton(frame, -1, " Exit ")
|
||||
b = wx.Button(frame, -1, " Exit ")
|
||||
frame.SetSize((200, 100))
|
||||
EVT_BUTTON(frame, b.GetId(), self.OnButton)
|
||||
wx.EVT_BUTTON(frame, b.GetId(), self.OnButton)
|
||||
else:
|
||||
# It was probably a dialog or something that is already
|
||||
# gone, so we're done.
|
||||
@@ -79,8 +81,8 @@ class RunDemoApp(wxApp):
|
||||
|
||||
self.SetTopWindow(frame)
|
||||
self.frame = frame
|
||||
#wxLog_SetActiveTarget(wxLogStderr())
|
||||
#wxLog_SetTraceMask(wxTraceMessages)
|
||||
#wx.Log_SetActiveTarget(wx.LogStderr())
|
||||
#wx.Log_SetTraceMask(wx.TraceMessages)
|
||||
return True
|
||||
|
||||
|
||||
|
@@ -5,38 +5,38 @@
|
||||
# structure of any wxPython application.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
import wx # This module uses the new wx namespace
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
class MyFrame(wx.Frame):
|
||||
"""
|
||||
This is MyFrame. It just shows a few controls on a wxPanel,
|
||||
and has a simple menu.
|
||||
"""
|
||||
def __init__(self, parent, title):
|
||||
wxFrame.__init__(self, parent, -1, title, size=(350, 200))
|
||||
wx.Frame.__init__(self, parent, -1, title, size=(350, 200))
|
||||
|
||||
menuBar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menuBar = wx.MenuBar()
|
||||
menu = wx.Menu()
|
||||
menu.Append(101, "E&xit\tAlt-X", "Exit demo")
|
||||
EVT_MENU(self, 101, self.OnButton)
|
||||
wx.EVT_MENU(self, 101, self.OnButton)
|
||||
menuBar.Append(menu, "&File")
|
||||
self.SetMenuBar(menuBar)
|
||||
|
||||
panel = wxPanel(self, -1)
|
||||
text = wxStaticText(panel, -1, "Hello World!")
|
||||
text.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
|
||||
panel = wx.Panel(self, -1)
|
||||
text = wx.StaticText(panel, -1, "Hello World!")
|
||||
text.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD))
|
||||
text.SetSize(text.GetBestSize())
|
||||
btn = wxButton(panel, -1, "Close")
|
||||
btn = wx.Button(panel, -1, "Close")
|
||||
btn.SetDefault()
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
sizer.Add(text, 0, wxALL, 10)
|
||||
sizer.Add(btn, 0, wxALL, 10)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
sizer.Add(text, 0, wx.ALL, 10)
|
||||
sizer.Add(btn, 0, wx.ALL, 10)
|
||||
panel.SetSizer(sizer)
|
||||
panel.SetAutoLayout(True)
|
||||
panel.Layout()
|
||||
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnButton)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnButton)
|
||||
|
||||
|
||||
def OnButton(self, evt):
|
||||
@@ -44,7 +44,8 @@ class MyFrame(wxFrame):
|
||||
print "OnButton"
|
||||
self.Close()
|
||||
|
||||
app = wxPySimpleApp()
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frame = MyFrame(None, "Simple wxPython App")
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
|
@@ -1,12 +1,12 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import wx # This module uses the new wx namespace
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
@@ -61,7 +61,7 @@ class TestPanel(wxPanel):
|
||||
|
||||
monthlist = GetMonthList()
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
self.date = wxComboBox(self, mID, "",
|
||||
wxPoint(100, 20), wxSize(90, -1),
|
||||
monthlist, wxCB_DROPDOWN)
|
||||
@@ -89,7 +89,7 @@ class TestPanel(wxPanel):
|
||||
|
||||
# scroll bar for month selection
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
self.scroll = wxScrollBar(self, mID, wxPoint(100, 240), wxSize(200, 20), wxSB_HORIZONTAL)
|
||||
self.scroll.SetScrollbar(start_month-1, 1, 12, 1, True)
|
||||
EVT_COMMAND_SCROLL(self, mID, self.Scroll)
|
||||
@@ -99,7 +99,7 @@ class TestPanel(wxPanel):
|
||||
self.dtext = wxTextCtrl(self, -1, str(start_year), wxPoint(200, 20), wxSize(60, -1))
|
||||
h = self.dtext.GetSize().height
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
self.spin = wxSpinButton(self, mID, wxPoint(270, 20), wxSize(h*2, h))
|
||||
self.spin.SetRange(1980, 2010)
|
||||
self.spin.SetValue(start_year)
|
||||
@@ -109,7 +109,7 @@ class TestPanel(wxPanel):
|
||||
|
||||
wxStaticText(self, -1, "Test Calendar Dialog", wxPoint(350, 50), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
bmp = images.getCalendarBitmap()
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 80))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.TestDlg)
|
||||
@@ -118,13 +118,13 @@ class TestPanel(wxPanel):
|
||||
|
||||
wxStaticText(self, -1, "Test Calendar Window", wxPoint(350, 150), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 180))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.TestFrame)
|
||||
|
||||
wxStaticText(self, -1, "Test Calendar Print", wxPoint(350, 250), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 280))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.OnPreview)
|
||||
|
||||
@@ -299,17 +299,17 @@ class CalendFrame(wxFrame):
|
||||
def MakeFileMenu(self):
|
||||
menu = wxMenu()
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
menu.Append(mID, 'Decrement', 'Next')
|
||||
EVT_MENU(self, mID, self.OnDecMonth)
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
menu.Append(mID, 'Increment', 'Dec')
|
||||
EVT_MENU(self, mID, self.OnIncMonth)
|
||||
|
||||
menu.AppendSeparator()
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
menu.Append(mID, 'E&xit', 'Exit')
|
||||
EVT_MENU(self, mID, self.OnCloseWindow)
|
||||
|
||||
@@ -318,23 +318,23 @@ class CalendFrame(wxFrame):
|
||||
def MakeToolMenu(self):
|
||||
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
SetToolPath(self, tb, mID, images.getDbDecBitmap(), 'Dec Year')
|
||||
EVT_TOOL(self, mID, self.OnDecYear)
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
SetToolPath(self, tb, mID, images.getDecBitmap(), 'Dec Month')
|
||||
EVT_TOOL(self, mID, self.OnDecMonth)
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
SetToolPath(self, tb, mID, images.getPtBitmap(), 'Current Month')
|
||||
EVT_TOOL(self, mID, self.OnCurrent)
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
SetToolPath(self, tb, mID, images.getIncBitmap(), 'Inc Month')
|
||||
EVT_TOOL(self, mID, self.OnIncMonth)
|
||||
|
||||
mID = NewId()
|
||||
mID = wxNewId()
|
||||
SetToolPath(self, tb, mID, images.getDbIncBitmap(), 'Inc Year')
|
||||
EVT_TOOL(self, mID, self.OnIncYear)
|
||||
|
||||
|
@@ -11,7 +11,10 @@ class TestPanel(wxPanel):
|
||||
self.log = log
|
||||
|
||||
cal = wxCalendarCtrl(self, -1, wxDateTime_Now(), pos = (25,50),
|
||||
style = wxCAL_SHOW_HOLIDAYS | wxCAL_SUNDAY_FIRST)
|
||||
style = wxCAL_SHOW_HOLIDAYS
|
||||
| wxCAL_SUNDAY_FIRST
|
||||
#| wxCAL_SEQUENTIAL_MONTH_SELECTION
|
||||
)
|
||||
|
||||
EVT_CALENDAR(self, cal.GetId(), self.OnCalSelected)
|
||||
|
||||
@@ -55,3 +58,12 @@ version described in the docs. This one will probably be a bit more efficient
|
||||
than the one in wxPython.lib.calendar, but I like a few things about it better,
|
||||
so I think both will stay in wxPython.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class TestCheckBox(wxPanel):
|
||||
wxStaticText(self, -1, "This example uses the wxCheckBox control.",
|
||||
wxPoint(10, 10))
|
||||
|
||||
cID = NewId()
|
||||
cID = wxNewId()
|
||||
cb1 = wxCheckBox(self, cID, " Apples", wxPoint(65, 40), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2 = wxCheckBox(self, cID+1, " Oranges", wxPoint(65, 60), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2.SetValue(True)
|
||||
@@ -51,3 +51,11 @@ overview = """\
|
||||
A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark).
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -70,13 +70,15 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -46,3 +46,13 @@ def runTest(frame, nb, log):
|
||||
overview = """\
|
||||
A choice item is used to select one of a list of strings. Unlike a listbox, only the selection is visible until the user pulls down the menu of choices.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -29,3 +29,13 @@ This class represents the colour chooser dialog.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -15,6 +15,7 @@ class TestComboBox(wxPanel):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
##'this is a long item that needs a scrollbar...',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxComboBox control.",
|
||||
@@ -23,6 +24,11 @@ class TestComboBox(wxPanel):
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18))
|
||||
cb = wxComboBox(self, 500, "default value", wxPoint(90, 50), wxSize(95, -1),
|
||||
sampleList, wxCB_DROPDOWN)#|wxTE_PROCESS_ENTER)
|
||||
##import win32api, win32con
|
||||
##win32api.SendMessage(cb.GetHandle(),
|
||||
## win32con.CB_SETHORIZONTALEXTENT,
|
||||
## 200, 0)
|
||||
|
||||
EVT_COMBOBOX(self, 500, self.EvtComboBox)
|
||||
EVT_TEXT(self, 500, self.EvtText)
|
||||
EVT_TEXT_ENTER(self, 500, self.EvtTextEnter)
|
||||
|
@@ -40,3 +40,12 @@ overview = """\
|
||||
This class provides a composite control that lets the
|
||||
user easily enter and edit a list of strings.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import os
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -8,12 +9,18 @@ wildcard = "Python source (*.py)|*.py|" \
|
||||
"All files (*.*)|*.*"
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFileDialog(frame, "Choose a file", "", "", wildcard, wxOPEN|wxMULTIPLE)
|
||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
||||
dlg = wxFileDialog(frame, "Choose a file", os.getcwd(), "", wildcard,
|
||||
wxOPEN
|
||||
| wxMULTIPLE
|
||||
#| wxCHANGE_DIR
|
||||
)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
paths = dlg.GetPaths()
|
||||
log.WriteText('You selected %d files:' % len(paths))
|
||||
for path in paths:
|
||||
log.WriteText(' %s\n' % path)
|
||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -24,14 +31,14 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the file chooser dialog.
|
||||
This class provides the file chooser dialog.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
44
wxPython/demo/wxFileDialog_Save.py
Normal file
44
wxPython/demo/wxFileDialog_Save.py
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import os
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
wildcard = "Python source (*.py)|*.py|" \
|
||||
"Compiled Python (*.pyc)|*.pyc|" \
|
||||
"SPAM files (*.spam)|*.spam|" \
|
||||
"Egg file (*.egg)|*.egg|" \
|
||||
"All files (*.*)|*.*"
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
||||
dlg = wxFileDialog(frame, "Save file as...", os.getcwd(), "", wildcard,
|
||||
wxSAVE
|
||||
#| wxCHANGE_DIR
|
||||
)
|
||||
dlg.SetFilterIndex(2)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
path = dlg.GetPath()
|
||||
log.WriteText('You selected "%s"' % path)
|
||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class provides the file chooser dialog.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -76,3 +76,12 @@ def runTest(frame, nb, log):
|
||||
overview = """\
|
||||
A generic find and replace dialog.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -75,9 +75,11 @@ def runTest(frame, nb, log):
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
overview = """\
|
||||
wxFloatBar is a subclass of wxToolBar, implemented in Python, which can be detached from its frame.
|
||||
wxFloatBar is a subclass of wxToolBar, implemented in Python, which
|
||||
can be detached from its frame.
|
||||
|
||||
Drag the toolbar with the mouse to make it float, and drag it back, or close it to make the toolbar return to its original position.
|
||||
Drag the toolbar with the mouse to make it float, and drag it back, or
|
||||
close it to make the toolbar return to its original position.
|
||||
|
||||
"""
|
||||
|
||||
@@ -87,6 +89,13 @@ Drag the toolbar with the mouse to make it float, and drag it back, or close it
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -43,3 +43,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -52,3 +52,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -57,3 +57,10 @@ overview = """\
|
||||
This control can be used to place a directory listing (with optional files)
|
||||
on an arbitrary window.
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -11,6 +11,7 @@ buttonDefs = {
|
||||
819 : ('GridEnterHandler',' Remapping keys to behave differently '),
|
||||
820 : ('GridCustEditor', ' Shows how to create a custom Cell Editor '),
|
||||
821 : ('GridDragable', ' A wxGrid with dragable rows and columns '),
|
||||
822 : ('GridDragAndDrop', 'Shows how to make a grid a drop target for files'),
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +27,7 @@ class ButtonPanel(wxPanel):
|
||||
for k in keys:
|
||||
text = buttonDefs[k][1]
|
||||
btn = wxButton(self, k, text)
|
||||
box.Add(btn, 0, wxALIGN_CENTER|wxALL, 15)
|
||||
box.Add(btn, 0, wxALIGN_CENTER|wxALL, 10)
|
||||
EVT_BUTTON(self, k, self.OnButton)
|
||||
|
||||
self.SetAutoLayout(True)
|
||||
@@ -94,9 +95,6 @@ changes how the ENTER key works, moving the current cell left to right
|
||||
and wrapping around to the next row when needed.
|
||||
</ol>
|
||||
<p>
|
||||
You can also look at the <a href="data/grid.i">SWIG interface
|
||||
file</a> used to generate the grid module for a lot more clues as to
|
||||
how things work.
|
||||
|
||||
"""
|
||||
|
||||
|
451
wxPython/demo/wxGrid_MegaExample.py
Normal file
451
wxPython/demo/wxGrid_MegaExample.py
Normal file
@@ -0,0 +1,451 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.grid import *
|
||||
import images
|
||||
|
||||
class MegaTable(wxPyGridTableBase):
|
||||
"""
|
||||
A custom wxGrid Table using user supplied data
|
||||
"""
|
||||
def __init__(self, data, colnames, plugins):
|
||||
"""data is a list of the form
|
||||
[(rowname, dictionary),
|
||||
dictionary.get(colname, None) returns the data for column
|
||||
colname
|
||||
"""
|
||||
# The base class must be initialized *first*
|
||||
wxPyGridTableBase.__init__(self)
|
||||
self.data = data
|
||||
self.colnames = colnames
|
||||
self.plugins = plugins or {}
|
||||
# XXX
|
||||
# we need to store the row length and collength to
|
||||
# see if the table has changed size
|
||||
self._rows = self.GetNumberRows()
|
||||
self._cols = self.GetNumberCols()
|
||||
|
||||
def GetNumberCols(self):
|
||||
return len(self.colnames)
|
||||
|
||||
def GetNumberRows(self):
|
||||
return len(self.data)
|
||||
|
||||
def GetColLabelValue(self, col):
|
||||
return self.colnames[col]
|
||||
|
||||
def GetRowLabelValues(self, row):
|
||||
return self.data[row][0]
|
||||
|
||||
def GetValue(self, row, col):
|
||||
return str(self.data[row][1].get(self.GetColLabelValue(col), ""))
|
||||
|
||||
def GetRawValue(self, row, col):
|
||||
return self.data[row][1].get(self.GetColLabelValue(col), "")
|
||||
|
||||
def SetValue(self, row, col, value):
|
||||
self.data[row][1][self.GetColLabelValue(col)] = value
|
||||
|
||||
def ResetView(self, grid):
|
||||
"""
|
||||
(wxGrid) -> Reset the grid view. Call this to
|
||||
update the grid if rows and columns have been added or deleted
|
||||
"""
|
||||
grid.BeginBatch()
|
||||
for current, new, delmsg, addmsg in [
|
||||
(self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED),
|
||||
(self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED),
|
||||
]:
|
||||
if new < current:
|
||||
msg = wxGridTableMessage(self,delmsg,new,current-new)
|
||||
grid.ProcessTableMessage(msg)
|
||||
elif new > current:
|
||||
msg = wxGridTableMessage(self,addmsg,new-current)
|
||||
grid.ProcessTableMessage(msg)
|
||||
self.UpdateValues(grid)
|
||||
grid.EndBatch()
|
||||
|
||||
self._rows = self.GetNumberRows()
|
||||
self._cols = self.GetNumberCols()
|
||||
# update the column rendering plugins
|
||||
self._updateColAttrs(grid)
|
||||
|
||||
# update the scrollbars and the displayed part of the grid
|
||||
grid.AdjustScrollbars()
|
||||
grid.ForceRefresh()
|
||||
|
||||
|
||||
def UpdateValues(self, grid):
|
||||
"""Update all displayed values"""
|
||||
# This sends an event to the grid table to update all of the values
|
||||
msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
|
||||
grid.ProcessTableMessage(msg)
|
||||
|
||||
def _updateColAttrs(self, grid):
|
||||
"""
|
||||
wxGrid -> update the column attributes to add the
|
||||
appropriate renderer given the column name. (renderers
|
||||
are stored in the self.plugins dictionary)
|
||||
|
||||
Otherwise default to the default renderer.
|
||||
"""
|
||||
col = 0
|
||||
for colname in self.colnames:
|
||||
attr = wxGridCellAttr()
|
||||
if colname in self.plugins:
|
||||
renderer = self.plugins[colname](self)
|
||||
if renderer.colSize:
|
||||
grid.SetColSize(col, renderer.colSize)
|
||||
if renderer.rowSize:
|
||||
grid.SetDefaultRowSize(renderer.rowSize)
|
||||
attr.SetReadOnly(true)
|
||||
attr.SetRenderer(renderer)
|
||||
grid.SetColAttr(col, attr)
|
||||
col += 1
|
||||
|
||||
# ------------------------------------------------------
|
||||
# begin the added code to manipulate the table (non wx related)
|
||||
def AppendRow(self, row):
|
||||
entry = {}
|
||||
for name in self.colnames:
|
||||
entry[name] = "Appended_%i"%row
|
||||
# XXX Hack
|
||||
# entry["A"] can only be between 1..4
|
||||
entry["A"] = random.choice(range(4))
|
||||
self.data.insert(row, ["Append_%i"%row, entry])
|
||||
|
||||
def DeleteCols(self, cols):
|
||||
"""
|
||||
cols -> delete the columns from the dataset
|
||||
cols hold the column indices
|
||||
"""
|
||||
# we'll cheat here and just remove the name from the
|
||||
# list of column names. The data will remain but
|
||||
# it won't be shown
|
||||
deleteCount = 0
|
||||
cols = cols[:]
|
||||
cols.sort()
|
||||
for i in cols:
|
||||
self.colnames.pop(i-deleteCount)
|
||||
# we need to advance the delete count
|
||||
# to make sure we delete the right columns
|
||||
deleteCount += 1
|
||||
if not len(self.colnames):
|
||||
self.data = []
|
||||
|
||||
def DeleteRows(self, rows):
|
||||
"""
|
||||
rows -> delete the rows from the dataset
|
||||
rows hold the row indices
|
||||
"""
|
||||
deleteCount = 0
|
||||
rows = rows[:]
|
||||
rows.sort()
|
||||
for i in rows:
|
||||
self.data.pop(i-deleteCount)
|
||||
# we need to advance the delete count
|
||||
# to make sure we delete the right rows
|
||||
deleteCount += 1
|
||||
|
||||
def SortColumn(self, col):
|
||||
"""
|
||||
col -> sort the data based on the column indexed by col
|
||||
"""
|
||||
name = self.colnames[col]
|
||||
_data = []
|
||||
for row in self.data:
|
||||
rowname, entry = row
|
||||
_data.append((entry.get(name, None), row))
|
||||
|
||||
_data.sort()
|
||||
self.data = []
|
||||
for sortvalue, row in _data:
|
||||
self.data.append(row)
|
||||
|
||||
# end table manipulation code
|
||||
# ----------------------------------------------------------
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Sample wxGrid renderers
|
||||
|
||||
class MegaImageRenderer(wxPyGridCellRenderer):
|
||||
def __init__(self, table):
|
||||
"""
|
||||
Image Renderer Test. This just places an image in a cell
|
||||
based on the row index. There are N choices and the
|
||||
choice is made by choice[row%N]
|
||||
"""
|
||||
wxPyGridCellRenderer.__init__(self)
|
||||
self.table = table
|
||||
self._choices = [images.getSmilesBitmap,
|
||||
images.getMondrianBitmap,
|
||||
images.get_10s_Bitmap,
|
||||
images.get_01c_Bitmap]
|
||||
|
||||
|
||||
self.colSize = None
|
||||
self.rowSize = None
|
||||
|
||||
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
|
||||
choice = self.table.GetRawValue(row, col)
|
||||
bmp = self._choices[ choice % len(self._choices)]()
|
||||
image = wxMemoryDC()
|
||||
image.SelectObject(bmp)
|
||||
|
||||
# clear the background
|
||||
dc.SetBackgroundMode(wxSOLID)
|
||||
if isSelected:
|
||||
dc.SetBrush(wxBrush(wxBLUE, wxSOLID))
|
||||
dc.SetPen(wxPen(wxBLUE, 1, wxSOLID))
|
||||
else:
|
||||
dc.SetBrush(wxBrush(wxWHITE, wxSOLID))
|
||||
dc.SetPen(wxPen(wxWHITE, 1, wxSOLID))
|
||||
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
|
||||
|
||||
# copy the image but only to the size of the grid cell
|
||||
width, height = bmp.GetWidth(), bmp.GetHeight()
|
||||
if width > rect.width-2:
|
||||
width = rect.width-2
|
||||
|
||||
if height > rect.height-2:
|
||||
height = rect.height-2
|
||||
|
||||
dc.Blit(rect.x+1, rect.y+1, width, height,
|
||||
image,
|
||||
0, 0, wxCOPY, True)
|
||||
|
||||
|
||||
class MegaFontRenderer(wxPyGridCellRenderer):
|
||||
def __init__(self, table, color="blue", font="ARIAL", fontsize=8):
|
||||
"""Render data in the specified color and font and fontsize"""
|
||||
wxPyGridCellRenderer.__init__(self)
|
||||
self.table = table
|
||||
self.color = color
|
||||
self.font = wxFont(fontsize, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||
0, font)
|
||||
self.selectedBrush = wxBrush("blue",
|
||||
wxSOLID)
|
||||
self.normalBrush = wxBrush(wxWHITE, wxSOLID)
|
||||
self.colSize = None
|
||||
self.rowSize = 50
|
||||
|
||||
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
|
||||
# Here we draw text in a grid cell using various fonts
|
||||
# and colors. We have to set the clipping region on
|
||||
# the grid's DC, otherwise the text will spill over
|
||||
# to the next cell
|
||||
dc.SetClippingRect(rect)
|
||||
|
||||
# clear the background
|
||||
dc.SetBackgroundMode(wxSOLID)
|
||||
if isSelected:
|
||||
dc.SetBrush(wxBrush(wxBLUE, wxSOLID))
|
||||
dc.SetPen(wxPen(wxBLUE, 1, wxSOLID))
|
||||
else:
|
||||
dc.SetBrush(wxBrush(wxWHITE, wxSOLID))
|
||||
dc.SetPen(wxPen(wxWHITE, 1, wxSOLID))
|
||||
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
|
||||
|
||||
text = self.table.GetValue(row, col)
|
||||
dc.SetBackgroundMode(wxSOLID)
|
||||
|
||||
# change the text background based on whether the grid is selected
|
||||
# or not
|
||||
if isSelected:
|
||||
dc.SetBrush(self.selectedBrush)
|
||||
dc.SetTextBackground("blue")
|
||||
else:
|
||||
dc.SetBrush(self.normalBrush)
|
||||
dc.SetTextBackground("white")
|
||||
|
||||
dc.SetTextForeground(self.color)
|
||||
dc.SetFont(self.font)
|
||||
dc.DrawText(text, rect.x+1, rect.y+1)
|
||||
|
||||
# Okay, now for the advanced class :)
|
||||
# Let's add three dots "..."
|
||||
# to indicate that that there is more text to be read
|
||||
# when the text is larger than the grid cell
|
||||
|
||||
width, height = dc.GetTextExtent(text)
|
||||
if width > rect.width-2:
|
||||
width, height = dc.GetTextExtent("...")
|
||||
x = rect.x+1 + rect.width-2 - width
|
||||
dc.DrawRectangle(x, rect.y+1, width+1, height)
|
||||
dc.DrawText("...", x, rect.y+1)
|
||||
|
||||
dc.DestroyClippingRegion()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Sample Grid using a specialized table and renderers that can
|
||||
# be plugged in based on column names
|
||||
|
||||
class MegaGrid(wxGrid):
|
||||
def __init__(self, parent, data, colnames, plugins=None):
|
||||
"""parent, data, colnames, plugins=None
|
||||
Initialize a grid using the data defined in data and colnames
|
||||
(see MegaTable for a description of the data format)
|
||||
plugins is a dictionary of columnName -> column renderers.
|
||||
"""
|
||||
|
||||
# The base class must be initialized *first*
|
||||
wxGrid.__init__(self, parent, -1)
|
||||
self._table = MegaTable(data, colnames, plugins)
|
||||
self.SetTable(self._table)
|
||||
self._plugins = plugins
|
||||
|
||||
EVT_GRID_LABEL_RIGHT_CLICK(self, self.OnLabelRightClicked)
|
||||
|
||||
def Reset(self):
|
||||
"""reset the view based on the data in the table. Call
|
||||
this when rows are added or destroyed"""
|
||||
self._table.ResetView(self)
|
||||
|
||||
def OnLabelRightClicked(self, evt):
|
||||
# Did we click on a row or a column?
|
||||
row, col = evt.GetRow(), evt.GetCol()
|
||||
if row == -1: self.colPopup(col, evt)
|
||||
elif col == -1: self.rowPopup(row, evt)
|
||||
|
||||
def rowPopup(self, row, evt):
|
||||
"""(row, evt) -> display a popup menu when a row label is right clicked"""
|
||||
appendID = wxNewId()
|
||||
deleteID = wxNewId()
|
||||
x = self.GetRowSize(row)/2
|
||||
if not self.GetSelectedRows():
|
||||
self.SelectRow(row)
|
||||
menu = wxMenu()
|
||||
xo, yo = evt.GetPosition()
|
||||
menu.Append(appendID, "Append Row")
|
||||
menu.Append(deleteID, "Delete Row(s)")
|
||||
|
||||
def append(event, self=self, row=row):
|
||||
self._table.AppendRow(row)
|
||||
self.Reset()
|
||||
|
||||
def delete(event, self=self, row=row):
|
||||
rows = self.GetSelectedRows()
|
||||
self._table.DeleteRows(rows)
|
||||
self.Reset()
|
||||
|
||||
EVT_MENU(self, appendID, append)
|
||||
EVT_MENU(self, deleteID, delete)
|
||||
self.PopupMenu(menu, wxPoint(x, yo))
|
||||
menu.Destroy()
|
||||
|
||||
def colPopup(self, col, evt):
|
||||
"""(col, evt) -> display a popup menu when a column label is
|
||||
right clicked"""
|
||||
x = self.GetColSize(col)/2
|
||||
menu = wxMenu()
|
||||
id1 = wxNewId()
|
||||
sortID = wxNewId()
|
||||
|
||||
xo, yo = evt.GetPosition()
|
||||
self.SelectCol(col)
|
||||
cols = self.GetSelectedCols()
|
||||
self.Refresh()
|
||||
menu.Append(id1, "Delete Col(s)")
|
||||
menu.Append(sortID, "Sort Column")
|
||||
|
||||
def delete(event, self=self, col=col):
|
||||
cols = self.GetSelectedCols()
|
||||
self._table.DeleteCols(cols)
|
||||
self.Reset()
|
||||
|
||||
def sort(event, self=self, col=col):
|
||||
self._table.SortColumn(col)
|
||||
self.Reset()
|
||||
|
||||
EVT_MENU(self, id1, delete)
|
||||
if len(cols) == 1:
|
||||
EVT_MENU(self, sortID, sort)
|
||||
self.PopupMenu(menu, wxPoint(xo, 0))
|
||||
menu.Destroy()
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Test data
|
||||
# data is in the form
|
||||
# [rowname, dictionary]
|
||||
# where dictionary.get(colname, None) -> returns the value for the cell
|
||||
#
|
||||
# the colname must also be supplied
|
||||
import random
|
||||
colnames = ["Row", "This", "Is", "A", "Test"]
|
||||
|
||||
data = []
|
||||
for row in range(1000):
|
||||
d = {}
|
||||
for name in ["This", "Test", "Is"]:
|
||||
d[name] = random.random()
|
||||
d["Row"] = len(data)
|
||||
# XXX
|
||||
# the "A" column can only be between one and 4
|
||||
d["A"] = random.choice(range(4))
|
||||
data.append((str(row), d))
|
||||
|
||||
class MegaFontRendererFactory:
|
||||
def __init__(self, color, font, fontsize):
|
||||
"""
|
||||
(color, font, fontsize) -> set of a factory to generate
|
||||
renderers when called.
|
||||
func = MegaFontRenderFactory(color, font, fontsize)
|
||||
renderer = func(table)
|
||||
"""
|
||||
self.color = color
|
||||
self.font = font
|
||||
self.fontsize = fontsize
|
||||
|
||||
def __call__(self, table):
|
||||
return MegaFontRenderer(table, self.color, self.font, self.fontsize)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self, parent, plugins={"This":MegaFontRendererFactory("red", "ARIAL", 8),
|
||||
"A":MegaImageRenderer,
|
||||
"Test":MegaFontRendererFactory("orange", "TIMES", 24),}):
|
||||
wxFrame.__init__(self, parent, -1,
|
||||
"Test Frame", size=(640,480))
|
||||
|
||||
grid = MegaGrid(self, data, colnames, plugins)
|
||||
grid.Reset()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestFrame(frame)
|
||||
frame.otherWin = win
|
||||
win.Show(True)
|
||||
|
||||
|
||||
|
||||
overview = """Mega Grid Example
|
||||
|
||||
This example attempts to show many examples and tricks of
|
||||
using a virtual grid object. Hopefully the source isn't too jumbled.
|
||||
|
||||
Features:
|
||||
1) Uses a virtual grid
|
||||
2) Columns and rows have popup menus (right click on labels)
|
||||
3) Columns and rows can be deleted (i.e. table can be
|
||||
resized)
|
||||
4) Dynamic renderers. Renderers are plugins based on
|
||||
column header name. Shows a simple Font Renderer and
|
||||
an Image Renderer.
|
||||
|
||||
Look for XXX in the code to indicate some workarounds for non-obvious
|
||||
behavior and various hacks.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -35,3 +35,12 @@ overview = """\
|
||||
At long last there is finally a way to load any supported image type
|
||||
directly from any Python file-like object, such as a memory buffer
|
||||
using StringIO. """
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -195,3 +195,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -46,3 +46,11 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -114,10 +114,13 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
Objects of this class can be associated with a window to define its layout constraints, with respect to siblings or its parent.
|
||||
overview = """\<html><body>
|
||||
Objects of this class can be associated with a window to define its
|
||||
layout constraints, with respect to siblings or its parent.
|
||||
|
||||
The class consists of the following eight constraints of class wxIndividualLayoutConstraint, some or all of which should be accessed directly to set the appropriate constraints.
|
||||
The class consists of the following eight constraints of class
|
||||
wxIndividualLayoutConstraint, some or all of which should be accessed
|
||||
directly to set the appropriate constraints.
|
||||
|
||||
left: represents the left hand edge of the window
|
||||
|
||||
@@ -135,10 +138,21 @@ centreX: represents the horizontal centre point of the window
|
||||
|
||||
centreY: represents the vertical centre point of the window
|
||||
|
||||
Most constraints are initially set to have the relationship wxUnconstrained, which means that their values should be calculated by looking at known constraints. The exceptions are width and height, which are set to wxAsIs to ensure that if the user does not specify a constraint, the existing width and height will be used, to be compatible with panel items which often have take a default size. If the constraint is wxAsIs, the dimension will not be changed.
|
||||
Most constraints are initially set to have the relationship
|
||||
wxUnconstrained, which means that their values should be calculated by
|
||||
looking at known constraints. The exceptions are width and height,
|
||||
which are set to wxAsIs to ensure that if the user does not specify a
|
||||
constraint, the existing width and height will be used, to be
|
||||
compatible with panel items which often have take a default size. If
|
||||
the constraint is wxAsIs, the dimension will not be changed.
|
||||
|
||||
wxLayoutConstraints()
|
||||
-------------------------------------------
|
||||
|
||||
Constructor.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -98,6 +98,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
|
||||
self.list = TestListCtrl(self, tID,
|
||||
style=wxLC_REPORT | wxSUNKEN_BORDER
|
||||
| wxLC_EDIT_LABELS
|
||||
#| wxLC_NO_HEADER
|
||||
#| wxLC_VRULES | wxLC_HRULES
|
||||
)
|
||||
@@ -121,6 +122,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
EVT_LIST_COL_BEGIN_DRAG(self, tID, self.OnColBeginDrag)
|
||||
EVT_LIST_COL_DRAGGING(self, tID, self.OnColDragging)
|
||||
EVT_LIST_COL_END_DRAG(self, tID, self.OnColEndDrag)
|
||||
EVT_LIST_BEGIN_LABEL_EDIT(self, tID, self.OnBeginEdit)
|
||||
|
||||
EVT_LEFT_DCLICK(self.list, self.OnDoubleClick)
|
||||
EVT_RIGHT_DOWN(self.list, self.OnRightDown)
|
||||
@@ -218,6 +220,8 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
#event.Veto() # doesn't work
|
||||
# this does
|
||||
self.list.SetItemState(10, 0, wxLIST_STATE_SELECTED)
|
||||
event.Skip()
|
||||
|
||||
|
||||
def OnItemDeselected(self, evt):
|
||||
item = evt.GetItem()
|
||||
@@ -233,6 +237,10 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
self.log.WriteText("OnItemActivated: %s\nTopItem: %s" %
|
||||
(self.list.GetItemText(self.currentItem), self.list.GetTopItem()))
|
||||
|
||||
def OnBeginEdit(self, event):
|
||||
self.log.WriteText("OnBeginEdit")
|
||||
event.Allow()
|
||||
|
||||
def OnItemDelete(self, event):
|
||||
self.log.WriteText("OnItemDelete\n")
|
||||
|
||||
@@ -265,30 +273,30 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
def OnRightClick(self, event):
|
||||
self.log.WriteText("OnRightClick %s\n" % self.list.GetItemText(self.currentItem))
|
||||
|
||||
# only do this part the first time
|
||||
# only do this part the first time so the events are only bound once
|
||||
if not hasattr(self, "popupID1"):
|
||||
self.popupID1 = wxNewId()
|
||||
self.popupID2 = wxNewId()
|
||||
self.popupID3 = wxNewId()
|
||||
self.popupID4 = wxNewId()
|
||||
self.popupID5 = wxNewId()
|
||||
self.popupID6 = wxNewId()
|
||||
EVT_MENU(self, self.popupID1, self.OnPopupOne)
|
||||
EVT_MENU(self, self.popupID2, self.OnPopupTwo)
|
||||
EVT_MENU(self, self.popupID3, self.OnPopupThree)
|
||||
EVT_MENU(self, self.popupID4, self.OnPopupFour)
|
||||
EVT_MENU(self, self.popupID5, self.OnPopupFive)
|
||||
EVT_MENU(self, self.popupID6, self.OnPopupSix)
|
||||
|
||||
# make a menu
|
||||
menu = wxMenu()
|
||||
# Show how to put an icon in the menu
|
||||
item = wxMenuItem(menu, self.popupID1,"One")
|
||||
item.SetBitmap(images.getSmilesBitmap())
|
||||
menu.AppendItem(item)
|
||||
# add some other items
|
||||
menu.Append(self.popupID2, "Two")
|
||||
# add some items
|
||||
menu.Append(self.popupID1, "FindItem tests")
|
||||
# menu.Append(self.popupID2, "Two")
|
||||
menu.Append(self.popupID3, "ClearAll and repopulate")
|
||||
menu.Append(self.popupID4, "DeleteAllItems")
|
||||
menu.Append(self.popupID5, "GetItem")
|
||||
menu.Append(self.popupID6, "Edit")
|
||||
|
||||
# Popup the menu. If an item is selected then its handler
|
||||
# will be called before PopupMenu returns.
|
||||
@@ -308,8 +316,6 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
self.log.WriteText("Popup three\n")
|
||||
self.list.ClearAll()
|
||||
wxCallAfter(self.PopulateList)
|
||||
#wxYield()
|
||||
#self.PopulateList()
|
||||
|
||||
def OnPopupFour(self, event):
|
||||
self.list.DeleteAllItems()
|
||||
@@ -318,6 +324,10 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
item = self.list.GetItem(self.currentItem)
|
||||
print item.m_text, item.m_itemId, self.list.GetItemData(self.currentItem)
|
||||
|
||||
def OnPopupSix(self, event):
|
||||
self.list.EditLabel(self.currentItem)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
w,h = self.GetClientSizeTuple()
|
||||
self.list.SetDimensions(0, 0, w, h)
|
||||
|
@@ -53,7 +53,7 @@ class TestVirtualList(wxListCtrl):
|
||||
return item.GetText()
|
||||
|
||||
def OnItemDeselected(self, evt):
|
||||
print evt.m_itemIndex
|
||||
self.log.WriteText("OnItemDeselected: %s" % evt.m_itemIndex)
|
||||
|
||||
|
||||
#---------------------------------------------------
|
||||
|
@@ -52,3 +52,12 @@ it. Here are a couple samples of how to use it.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -51,13 +51,22 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
overview = """\
|
||||
wxMVCTree is a control which handles hierarchical data. It is constructed in model-view-controller architecture, so the display of that data, and the content of the data can be changed greatly without affecting the other parts.
|
||||
|
||||
wxMVCTree is a control which handles hierarchical data. It is
|
||||
constructed in model-view-controller architecture, so the display of
|
||||
that data, and the content of the data can be changed greatly without
|
||||
affecting the other parts.
|
||||
|
||||
Multiple selections are possible by holding down the Ctrl key.
|
||||
|
||||
This demo shows the wxPython directory structure. The interesting part is that the tree model is late-bound to the filesystem, so the filenames are not retrieved until the directory is expanded. In mvctree.py are models for generic data, and both the early and late-bound filesystem models.
|
||||
This demo shows the wxPython directory structure. The interesting part
|
||||
is that the tree model is late-bound to the filesystem, so the
|
||||
filenames are not retrieved until the directory is expanded. In
|
||||
mvctree.py are models for generic data, and both the early and
|
||||
late-bound filesystem models.
|
||||
|
||||
There is also support for editing, though it's not enabled in this demo, to avoid accidentally renaming files!
|
||||
There is also support for editing, though it's not enabled in this
|
||||
demo, to avoid accidentally renaming files!
|
||||
|
||||
"""
|
||||
|
||||
@@ -65,6 +74,7 @@ There is also support for editing, though it's not enabled in this demo, to avoi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import time
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
@@ -68,14 +70,24 @@ check the source for this sample to see how to implement them.
|
||||
|
||||
menu5 = wxMenu()
|
||||
menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
|
||||
|
||||
menu5.AppendSeparator()
|
||||
menu5.Append(502, "Hello\tShift+H")
|
||||
menu5.AppendSeparator()
|
||||
menu5.Append(503, "remove the submenu")
|
||||
menu6 = wxMenu()
|
||||
menu6.Append(601, "Submenu Item")
|
||||
menu5.AppendMenu(504, "submenu", menu6)
|
||||
menu5.Append(505, "remove this menu")
|
||||
menu5.Append(506, "this is updated")
|
||||
menu5.Append(507, "insert after this...")
|
||||
menu5.Append(508, "...and before this")
|
||||
menuBar.Append(menu5, "&Fun")
|
||||
|
||||
self.SetMenuBar(menuBar)
|
||||
|
||||
# Menu events
|
||||
EVT_MENU_HIGHLIGHT_ALL(self, self.OnMenuHighlight)
|
||||
|
||||
EVT_MENU(self, 101, self.Menu101)
|
||||
EVT_MENU(self, 102, self.Menu102)
|
||||
EVT_MENU(self, 103, self.Menu103)
|
||||
@@ -97,9 +109,25 @@ check the source for this sample to see how to implement them.
|
||||
|
||||
EVT_MENU(self, 501, self.Menu501)
|
||||
EVT_MENU(self, 502, self.Menu502)
|
||||
EVT_MENU(self, 503, self.TestRemove)
|
||||
EVT_MENU(self, 505, self.TestRemove2)
|
||||
EVT_MENU(self, 507, self.TestInsert)
|
||||
EVT_MENU(self, 508, self.TestInsert)
|
||||
|
||||
EVT_UPDATE_UI(wxGetApp(), 506, self.TestUpdateUI)
|
||||
|
||||
# Methods
|
||||
|
||||
def OnMenuHighlight(self, event):
|
||||
# Show how to get menu item imfo from this event handler
|
||||
id = event.GetMenuId()
|
||||
item = self.GetMenuBar().FindItemById(id)
|
||||
text = item.GetText()
|
||||
help = item.GetHelp()
|
||||
#print text, help
|
||||
event.Skip() # but in this case just call Skip so the default is done
|
||||
|
||||
|
||||
def Menu101(self, event):
|
||||
self.log.write('Welcome to Mercury\n')
|
||||
|
||||
@@ -146,8 +174,49 @@ check the source for this sample to see how to implement them.
|
||||
def Menu502(self, event):
|
||||
self.log.write('Hello from Jean-Michel\n')
|
||||
|
||||
|
||||
def TestRemove(self, evt):
|
||||
mb = self.GetMenuBar()
|
||||
submenuItem = mb.FindItemById(601)
|
||||
if not submenuItem:
|
||||
return
|
||||
submenu = submenuItem.GetMenu()
|
||||
menu = submenu.GetParent()
|
||||
|
||||
#menu.Remove(504) # works
|
||||
menu.RemoveItem(mb.FindItemById(504)) # this also works
|
||||
#menu.RemoveItem(submenuItem) # doesn't work, as expected since submenuItem is not on menu
|
||||
|
||||
|
||||
def TestRemove2(self, evt):
|
||||
mb = self.GetMenuBar()
|
||||
mb.Remove(4)
|
||||
|
||||
|
||||
def TestUpdateUI(self, evt):
|
||||
text = time.ctime()
|
||||
evt.SetText(text)
|
||||
|
||||
|
||||
def TestInsert(self, evt):
|
||||
# get the menu
|
||||
mb = self.GetMenuBar()
|
||||
menuItem = mb.FindItemById(507)
|
||||
menu = menuItem.GetMenu()
|
||||
|
||||
ID = wxNewId()
|
||||
##menu.Insert(9, ID, "NewItem " + str(ID))
|
||||
item = wxMenuItem(menu)
|
||||
item.SetId(ID)
|
||||
item.SetText("NewItem " + str(ID))
|
||||
menu.InsertItem(9, item)
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
wxRegisterId(10000)
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyFrame(frame, -1, log)
|
||||
frame.otherWin = win
|
||||
|
@@ -25,39 +25,14 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
overview = """\
|
||||
wxMessageDialog()
|
||||
----------------------------------
|
||||
|
||||
wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Message box", long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxMessageDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
caption = The dialog caption.
|
||||
|
||||
style = A dialog style (bitlist) containing flags chosen from the following:
|
||||
|
||||
wxOK Show an OK button.
|
||||
|
||||
wxCANCEL Show a Cancel button.
|
||||
|
||||
wxYES_NO Show Yes and No buttons.
|
||||
|
||||
wxCENTRE Centre the message. Not Windows.
|
||||
|
||||
wxICON_EXCLAMATION Shows an exclamation mark icon. Windows only.
|
||||
|
||||
wxICON_HAND Shows a hand icon. Windows only.
|
||||
|
||||
wxICON_QUESTION Shows a question mark icon. Windows only.
|
||||
|
||||
wxICON_INFORMATION Shows an information (i) icon. Windows only.
|
||||
|
||||
pos = Dialog position.
|
||||
Show a message to the user in a dialog
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -173,3 +173,11 @@ def MyBitmapsFunc( index ):
|
||||
mimetypes_wdr.MyBitmapsFunc = MyBitmapsFunc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -45,3 +45,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -25,3 +25,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -14,7 +14,7 @@ import sys
|
||||
class TestNB(wxNotebook):
|
||||
def __init__(self, parent, id, log):
|
||||
wxNotebook.__init__(self, parent, id, style=
|
||||
#0
|
||||
#wxNB_TOP
|
||||
wxNB_BOTTOM
|
||||
#wxNB_LEFT
|
||||
#wxNB_RIGHT
|
||||
@@ -59,11 +59,11 @@ class TestNB(wxNotebook):
|
||||
win = self.makeColorPanel(wxCYAN)
|
||||
self.AddPage(win, "Cyan")
|
||||
|
||||
win = self.makeColorPanel(wxWHITE)
|
||||
self.AddPage(win, "White")
|
||||
## win = self.makeColorPanel(wxWHITE)
|
||||
## self.AddPage(win, "White")
|
||||
|
||||
win = self.makeColorPanel(wxBLACK)
|
||||
self.AddPage(win, "Black")
|
||||
## win = self.makeColorPanel(wxBLACK)
|
||||
## self.AddPage(win, "Black")
|
||||
|
||||
win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
|
||||
self.AddPage(win, "MIDNIGHT BLUE")
|
||||
@@ -88,16 +88,17 @@ class TestNB(wxNotebook):
|
||||
def OnPageChanged(self, event):
|
||||
old = event.GetOldSelection()
|
||||
new = event.GetSelection()
|
||||
self.log.write('OnPageChanged, old:%d, new:%d\n' % (old, new))
|
||||
sel = self.GetSelection()
|
||||
self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel))
|
||||
event.Skip()
|
||||
|
||||
def OnPageChanging(self, event):
|
||||
old = event.GetOldSelection()
|
||||
new = event.GetSelection()
|
||||
self.log.write('OnPageChanging, old:%d, new:%d\n' % (old, new))
|
||||
sel = self.GetSelection()
|
||||
self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
|
||||
event.Skip()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
|
@@ -106,7 +106,7 @@ class MyEvtHandler(wxShapeEvtHandler):
|
||||
|
||||
def OnLeftClick(self, x, y, keys = 0, attachment = 0):
|
||||
shape = self.GetShape()
|
||||
print shape.__class__
|
||||
print shape.__class__, shape.GetClassName()
|
||||
canvas = shape.GetCanvas()
|
||||
dc = wxClientDC(canvas)
|
||||
canvas.PrepareDC(dc)
|
||||
|
@@ -21,13 +21,15 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -37,3 +37,11 @@ def runTest(frame, nb, log):
|
||||
overview = wxPlotCanvas.__doc__
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -5,12 +5,18 @@ from wxPython.wx import *
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
data = wxPrintDialogData()
|
||||
|
||||
data.EnableSelection(True)
|
||||
data.EnablePrintToFile(True)
|
||||
data.EnablePageNumbers(True)
|
||||
data.EnableSelection(True)
|
||||
data.SetMinPage(1)
|
||||
data.SetMaxPage(5)
|
||||
data.SetAllPages(True)
|
||||
|
||||
dlg = wxPrintDialog(frame, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('\n')
|
||||
data = dlg.GetPrintDialogData()
|
||||
log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -18,14 +24,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -152,3 +152,12 @@ child process to exit its main loop.
|
||||
|
||||
</body><html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -30,9 +30,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -47,3 +47,10 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = wxPython.lib.rightalign.__doc__
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -114,17 +114,13 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -17,8 +17,14 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -15,12 +15,14 @@ class TestPanel(wxScrolledPanel):
|
||||
desc = wxStaticText(self, -1,
|
||||
"wxScrolledPanel extends wxScrolledWindow, adding all "
|
||||
"the necessary bits to set up scroll handling for you.\n\n"
|
||||
"Here are three fixed size examples of its use, and the "
|
||||
"mail demo panel is also using it."
|
||||
"Here are three fixed size examples of its use. The "
|
||||
"demo panel for this sample is also using it -- the \nwxStaticLine"
|
||||
"below is intentionally made too long so a scrollbar will be "
|
||||
"activated."
|
||||
)
|
||||
desc.SetForegroundColour("Blue")
|
||||
vbox.Add(desc, 0, wxALIGN_LEFT|wxALL, 5)
|
||||
vbox.Add(wxStaticLine(self, -1), 0, wxEXPAND|wxALL, 5)
|
||||
vbox.Add(wxStaticLine(self, -1, size=(1024,-1)), 0, wxALL, 5)
|
||||
vbox.AddSpacer(20,20)
|
||||
|
||||
words = text.split()
|
||||
|
@@ -64,7 +64,7 @@ class MyCanvas(wxScrolledWindow):
|
||||
self.DoDrawing(dc)
|
||||
|
||||
|
||||
def DoDrawing(self, dc):
|
||||
def DoDrawing(self, dc, printing=False):
|
||||
dc.BeginDrawing()
|
||||
dc.SetPen(wxPen('RED'))
|
||||
dc.DrawRectangle(5, 5, 50, 50)
|
||||
@@ -92,6 +92,11 @@ class MyCanvas(wxScrolledWindow):
|
||||
dc.SetTextForeground(wxColour(0, 0xFF, 0x80))
|
||||
dc.DrawText("a bitmap", 200, 85)
|
||||
|
||||
## dc.SetFont(wxFont(14, wxSWISS, wxNORMAL, wxNORMAL))
|
||||
## dc.SetTextForeground("BLACK")
|
||||
## dc.DrawText("TEST this STRING", 10, 200)
|
||||
## print dc.GetFullTextExtent("TEST this STRING")
|
||||
|
||||
font = wxFont(20, wxSWISS, wxNORMAL, wxNORMAL)
|
||||
dc.SetFont(font)
|
||||
dc.SetTextForeground(wxBLACK)
|
||||
@@ -106,16 +111,20 @@ class MyCanvas(wxScrolledWindow):
|
||||
dc.SetPen(wxPen('RED'))
|
||||
dc.DrawEllipticArc(200, 500, 50, 75, 0, 90)
|
||||
|
||||
y = 20
|
||||
for style in [wxDOT, wxLONG_DASH, wxSHORT_DASH, wxDOT_DASH, wxUSER_DASH]:
|
||||
pen = wxPen("DARK ORCHID", 1, style)
|
||||
if style == wxUSER_DASH:
|
||||
pen.SetCap(wxCAP_BUTT)
|
||||
pen.SetDashes([1,2])
|
||||
pen.SetColour("RED")
|
||||
dc.SetPen(pen)
|
||||
dc.DrawLine(300, y, 400, y)
|
||||
y = y + 10
|
||||
if not printing:
|
||||
# This has troubles when used on a print preview in wxGTK,
|
||||
# probably something to do with the pen styles and the scaling
|
||||
# it does...
|
||||
y = 20
|
||||
for style in [wxDOT, wxLONG_DASH, wxSHORT_DASH, wxDOT_DASH, wxUSER_DASH]:
|
||||
pen = wxPen("DARK ORCHID", 1, style)
|
||||
if style == wxUSER_DASH:
|
||||
pen.SetCap(wxCAP_BUTT)
|
||||
pen.SetDashes([1,2])
|
||||
pen.SetColour("RED")
|
||||
dc.SetPen(pen)
|
||||
dc.DrawLine(300, y, 400, y)
|
||||
y = y + 10
|
||||
|
||||
dc.SetBrush(wxTRANSPARENT_BRUSH)
|
||||
dc.SetPen(wxPen(wxColour(0xFF, 0x20, 0xFF), 1, wxSOLID))
|
||||
|
@@ -16,17 +16,17 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents a dialog that shows a list of strings, and allows the user to select one. Double-clicking on a list item is equivalent to single-clicking and then pressing OK.
|
||||
This class represents a dialog that shows a list of strings, and allows the user
|
||||
to select one. Double-clicking on a list item is equivalent to single-clicking
|
||||
and then pressing OK.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -46,3 +46,10 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -34,3 +34,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -37,11 +37,6 @@ def runTest(frame, nb, log):
|
||||
splitter.SetMinimumPaneSize(20)
|
||||
splitter.SplitVertically(p1, p2, 100)
|
||||
|
||||
## splitter.SetSize((300,300))
|
||||
## print splitter.GetSashPosition()
|
||||
## splitter.SetSashPosition(100)
|
||||
## print splitter.GetSashPosition()
|
||||
|
||||
return splitter
|
||||
|
||||
|
||||
@@ -50,41 +45,16 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class manages up to two subwindows. The current view can be split into two programmatically (perhaps from a menu command), and unsplit either programmatically or via the wxSplitterWindow user interface.
|
||||
|
||||
wxSplitterWindow()
|
||||
-----------------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxSplitterWindow(wxWindow* parent, wxWindowID id, int x, const wxPoint& point = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style=wxSP_3D, const wxString& name = "splitterWindow")
|
||||
|
||||
Constructor for creating the window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The parent of the splitter window.
|
||||
|
||||
id = The window identifier.
|
||||
|
||||
pos = The window position.
|
||||
|
||||
size = The window size.
|
||||
|
||||
style = The window style. See wxSplitterWindow.
|
||||
|
||||
name = The window name.
|
||||
This class manages up to two subwindows. The current view can be split
|
||||
into two programmatically (perhaps from a menu command), and unsplit
|
||||
either programmatically or via the wxSplitterWindow user interface.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -38,10 +38,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -24,10 +24,9 @@ class TestPanel(wxPanel):
|
||||
|
||||
str = "This is a different font."
|
||||
text = wxStaticText(self, -1, str, (20, 100))
|
||||
font = wxFont(18, wxSWISS, wxNORMAL, wxNORMAL, False, "Arial")
|
||||
w, h, d, e = self.GetFullTextExtent(str, font)
|
||||
font = wxFont(18, wxSWISS, wxNORMAL, wxNORMAL)
|
||||
text.SetFont(font)
|
||||
text.SetSize(wxSize(w, h))
|
||||
#text.SetSize(text.GetBestSize())
|
||||
|
||||
wxStaticText(self, -1, "Multi-line wxStaticText\nline 2\nline 3\n\nafter empty line", (20,150))
|
||||
wxStaticText(self, -1, "Align right multi-line\nline 2\nline 3\n\nafter empty line", (220,150), style=wxALIGN_RIGHT)
|
||||
|
@@ -104,5 +104,16 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
overview = """\
|
||||
A status bar is a narrow window that can be placed along the bottom of a frame to give small amounts of status information. It can contain one or more fields, one or more of which can be variable length according to the size of the window.
|
||||
"""
|
||||
A status bar is a narrow window that can be placed along the bottom of
|
||||
a frame to give small amounts of status information. It can contain
|
||||
one or more fields, one or more of which can be variable length
|
||||
according to the size of the window. """
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -2,6 +2,8 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.stc import *
|
||||
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
debug = 1
|
||||
@@ -212,7 +214,8 @@ def runTest(frame, nb, log):
|
||||
# setup some markers
|
||||
ed.SetMarginType(1, wxSTC_MARGIN_SYMBOL)
|
||||
ed.MarkerDefine(0, wxSTC_MARK_ROUNDRECT, "#CCFF00", "RED")
|
||||
ed.MarkerDefine(1, wxSTC_MARK_CIRCLE, "FOREST GREEN", "SIENNA")
|
||||
#ed.MarkerDefine(1, wxSTC_MARK_CIRCLE, "FOREST GREEN", "SIENNA")
|
||||
ed.MarkerDefineBitmap(1, images.getFolder1Bitmap())
|
||||
ed.MarkerDefine(2, wxSTC_MARK_SHORTARROW, "blue", "blue")
|
||||
ed.MarkerDefine(3, wxSTC_MARK_ARROW, "#00FF00", "#00FF00")
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.stc import *
|
||||
|
||||
import images
|
||||
import keyword
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@@ -53,6 +53,7 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
|
||||
self.SetViewWhiteSpace(False)
|
||||
#self.SetBufferedDraw(False)
|
||||
#self.SetViewEOL(True)
|
||||
|
||||
self.SetEdgeMode(wxSTC_EDGE_BACKGROUND)
|
||||
self.SetEdgeColumn(78)
|
||||
@@ -85,6 +86,7 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
|
||||
EVT_STC_UPDATEUI(self, ID, self.OnUpdateUI)
|
||||
EVT_STC_MARGINCLICK(self, ID, self.OnMarginClick)
|
||||
EVT_KEY_DOWN(self, self.OnKeyPressed)
|
||||
|
||||
|
||||
# Make some styles, The lexer defines what each style is used for, we
|
||||
@@ -108,9 +110,9 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
# Number
|
||||
self.StyleSetSpec(wxSTC_P_NUMBER, "fore:#007F7F,size:%(size)d" % faces)
|
||||
# String
|
||||
self.StyleSetSpec(wxSTC_P_STRING, "fore:#7F007F,italic,face:%(times)s,size:%(size)d" % faces)
|
||||
self.StyleSetSpec(wxSTC_P_STRING, "fore:#7F007F,face:%(helv)s,size:%(size)d" % faces)
|
||||
# Single quoted string
|
||||
self.StyleSetSpec(wxSTC_P_CHARACTER, "fore:#7F007F,italic,face:%(times)s,size:%(size)d" % faces)
|
||||
self.StyleSetSpec(wxSTC_P_CHARACTER, "fore:#7F007F,face:%(helv)s,size:%(size)d" % faces)
|
||||
# Keyword
|
||||
self.StyleSetSpec(wxSTC_P_WORD, "fore:#00007F,bold,size:%(size)d" % faces)
|
||||
# Triple quotes
|
||||
@@ -130,10 +132,15 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
# End of line where string is not closed
|
||||
self.StyleSetSpec(wxSTC_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % faces)
|
||||
|
||||
|
||||
self.SetCaretForeground("BLUE")
|
||||
|
||||
EVT_KEY_DOWN(self, self.OnKeyPressed)
|
||||
|
||||
# register some images for use in the AutoComplete box.
|
||||
self.RegisterImage(1, images.getSmilesBitmap())
|
||||
self.RegisterImage(2, images.getFile1Bitmap())
|
||||
self.RegisterImage(3, images.getCopyBitmap())
|
||||
|
||||
|
||||
|
||||
|
||||
def OnKeyPressed(self, event):
|
||||
@@ -145,7 +152,9 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
# Tips
|
||||
if event.ShiftDown():
|
||||
self.CallTipSetBackground("yellow")
|
||||
self.CallTipShow(pos, 'param1, param2')
|
||||
self.CallTipShow(pos, 'lots of of text: blah, blah, blah\n\n'
|
||||
'show some suff, maybe parameters..\n\n'
|
||||
'fubar(param1, param2)')
|
||||
# Code completion
|
||||
else:
|
||||
#lst = []
|
||||
@@ -156,17 +165,22 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
#self.AutoCompShow(0, st)
|
||||
|
||||
kw = keyword.kwlist[:]
|
||||
kw.append("zzzzzz")
|
||||
kw.append("aaaaa")
|
||||
kw.append("__init__")
|
||||
kw.append("zzaaaaa")
|
||||
kw.append("zzbaaaa")
|
||||
kw.append("zzzzzz?2")
|
||||
kw.append("aaaaa?2")
|
||||
kw.append("__init__?3")
|
||||
kw.append("zzaaaaa?2")
|
||||
kw.append("zzbaaaa?2")
|
||||
kw.append("this_is_a_longer_value")
|
||||
kw.append("this_is_a_much_much_much_much_much_much_much_longer_value")
|
||||
#kw.append("this_is_a_much_much_much_much_much_much_much_longer_value")
|
||||
|
||||
kw.sort() # Python sorts are case sensitive
|
||||
self.AutoCompSetIgnoreCase(False) # so this needs to match
|
||||
|
||||
# Images are specified with a appended "?type"
|
||||
for i in range(len(kw)):
|
||||
if kw[i] in keyword.kwlist:
|
||||
kw[i] = kw[i] + "?1"
|
||||
|
||||
self.AutoCompShow(0, " ".join(kw))
|
||||
else:
|
||||
event.Skip()
|
||||
|
@@ -17,14 +17,15 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -1,68 +1,114 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.timectrl import *
|
||||
from wxPython.lib.timectrl import __doc__ as overviewdoc
|
||||
from wxPython.lib.scrolledpanel import wxScrolledPanel
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel( wxPanel ):
|
||||
class TestPanel( wxScrolledPanel ):
|
||||
def __init__( self, parent, log ):
|
||||
|
||||
wxPanel.__init__( self, parent, -1 )
|
||||
wxScrolledPanel.__init__( self, parent, -1 )
|
||||
self.log = log
|
||||
panel = wxPanel( self, -1 )
|
||||
|
||||
grid = wxFlexGridSizer( 0, 2, 20, 0 )
|
||||
|
||||
text1 = wxStaticText( panel, 10, "A 12-hour format wxTimeCtrl:")
|
||||
self.time12 = wxTimeCtrl( panel, 20, name="12 hour control" )
|
||||
spin1 = wxSpinButton( panel, 30, wxDefaultPosition, wxSize(-1,20), 0 )
|
||||
text1 = wxStaticText( self, -1, "12-hour format:")
|
||||
self.time12 = wxTimeCtrl( self, -1, name="12 hour control" )
|
||||
spin1 = wxSpinButton( self, -1, wxDefaultPosition, wxSize(-1,20), 0 )
|
||||
self.time12.BindSpinButton( spin1 )
|
||||
|
||||
grid.AddWindow( text1, 0, wxALIGN_RIGHT, 5 )
|
||||
text2 = wxStaticText( self, -1, "24-hour format:")
|
||||
spin2 = wxSpinButton( self, -1, wxDefaultPosition, wxSize(-1,20), 0 )
|
||||
self.time24 = wxTimeCtrl( self, -1, name="24 hour control", fmt24hr=True, spinButton = spin2 )
|
||||
|
||||
text3 = wxStaticText( self, -1, "No seconds\nor spin button:")
|
||||
self.spinless_ctrl = wxTimeCtrl( self, -1, name="spinless control", display_seconds = False )
|
||||
|
||||
grid = wxFlexGridSizer( 0, 2, 10, 5 )
|
||||
grid.Add( text1, 0, wxALIGN_RIGHT )
|
||||
hbox1 = wxBoxSizer( wxHORIZONTAL )
|
||||
hbox1.AddWindow( self.time12, 0, wxALIGN_CENTRE, 5 )
|
||||
hbox1.AddWindow( spin1, 0, wxALIGN_CENTRE, 5 )
|
||||
grid.AddSizer( hbox1, 0, wxLEFT, 5 )
|
||||
hbox1.Add( self.time12, 0, wxALIGN_CENTRE )
|
||||
hbox1.Add( spin1, 0, wxALIGN_CENTRE )
|
||||
grid.Add( hbox1, 0, wxLEFT )
|
||||
|
||||
|
||||
text2 = wxStaticText( panel, 40, "A 24-hour format wxTimeCtrl:")
|
||||
self.time24 = wxTimeCtrl( panel, 50, fmt24hr=True, name="24 hour control" )
|
||||
spin2 = wxSpinButton( panel, 60, wxDefaultPosition, wxSize(-1,20), 0 )
|
||||
self.time24.BindSpinButton( spin2 )
|
||||
|
||||
grid.AddWindow( text2, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
grid.Add( text2, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM )
|
||||
hbox2 = wxBoxSizer( wxHORIZONTAL )
|
||||
hbox2.AddWindow( self.time24, 0, wxALIGN_CENTRE, 5 )
|
||||
hbox2.AddWindow( spin2, 0, wxALIGN_CENTRE, 5 )
|
||||
grid.AddSizer( hbox2, 0, wxLEFT, 5 )
|
||||
hbox2.Add( self.time24, 0, wxALIGN_CENTRE )
|
||||
hbox2.Add( spin2, 0, wxALIGN_CENTRE )
|
||||
grid.Add( hbox2, 0, wxLEFT )
|
||||
|
||||
grid.Add( text3, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM )
|
||||
grid.Add( self.spinless_ctrl, 0, wxLEFT )
|
||||
|
||||
|
||||
text3 = wxStaticText( panel, 70, "A wxTimeCtrl without a spin button:")
|
||||
self.spinless_ctrl = wxTimeCtrl( panel, 80, name="spinless control" )
|
||||
|
||||
grid.AddWindow( text3, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
grid.AddWindow( self.spinless_ctrl, 0, wxLEFT, 5 )
|
||||
|
||||
|
||||
buttonChange = wxButton( panel, 100, "Change Controls")
|
||||
self.radio12to24 = wxRadioButton( panel, 110, "Copy 12-hour time to 24-hour control", wxDefaultPosition, wxDefaultSize, wxRB_GROUP )
|
||||
self.radio24to12 = wxRadioButton( panel, 120, "Copy 24-hour time to 12-hour control")
|
||||
self.radioWx = wxRadioButton( panel, 130, "Set controls to 'now' using wxDateTime")
|
||||
self.radioMx = wxRadioButton( panel, 140, "Set controls to 'now' using mxDateTime")
|
||||
buttonChange = wxButton( self, -1, "Change Controls")
|
||||
self.radio12to24 = wxRadioButton( self, -1, "Copy 12-hour time to 24-hour control", wxDefaultPosition, wxDefaultSize, wxRB_GROUP )
|
||||
self.radio24to12 = wxRadioButton( self, -1, "Copy 24-hour time to 12-hour control")
|
||||
self.radioWx = wxRadioButton( self, -1, "Set controls to 'now' using wxDateTime")
|
||||
self.radioMx = wxRadioButton( self, -1, "Set controls to 'now' using mxDateTime")
|
||||
|
||||
radio_vbox = wxBoxSizer( wxVERTICAL )
|
||||
radio_vbox.AddWindow( self.radio12to24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.AddWindow( self.radio24to12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.AddWindow( self.radioWx, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.AddWindow( self.radioMx, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.Add( self.radio12to24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.Add( self.radio24to12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.Add( self.radioWx, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.Add( self.radioMx, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
|
||||
box_label = wxStaticBox( panel, 90, "Change Controls through API" )
|
||||
box_label = wxStaticBox( self, -1, "Change Controls through API" )
|
||||
buttonbox = wxStaticBoxSizer( box_label, wxHORIZONTAL )
|
||||
buttonbox.AddWindow( buttonChange, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
buttonbox.AddSizer( radio_vbox, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
buttonbox.Add( buttonChange, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
buttonbox.Add( radio_vbox, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
hbox = wxBoxSizer( wxHORIZONTAL )
|
||||
hbox.Add( grid, 0, wxALIGN_LEFT|wxALL, 15 )
|
||||
hbox.Add( buttonbox, 0, wxALIGN_RIGHT|wxBOTTOM, 20 )
|
||||
|
||||
|
||||
box_label = wxStaticBox( self, -1, "Bounds Control" )
|
||||
boundsbox = wxStaticBoxSizer( box_label, wxHORIZONTAL )
|
||||
self.set_bounds = wxCheckBox( self, -1, "Set time bounds:" )
|
||||
|
||||
minlabel = wxStaticText( self, -1, "minimum time:" )
|
||||
self.min = wxTimeCtrl( self, -1, name="min", display_seconds = False )
|
||||
self.min.Enable( False )
|
||||
|
||||
maxlabel = wxStaticText( self, -1, "maximum time:" )
|
||||
self.max = wxTimeCtrl( self, -1, name="max", display_seconds = False )
|
||||
self.max.Enable( False )
|
||||
|
||||
self.limit_check = wxCheckBox( self, -1, "Limit control" )
|
||||
|
||||
label = wxStaticText( self, -1, "Resulting time control:" )
|
||||
self.target_ctrl = wxTimeCtrl( self, -1, name="new" )
|
||||
|
||||
grid2 = wxFlexGridSizer( 0, 2, 0, 0 )
|
||||
grid2.Add( 20, 0, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
grid2.Add( 20, 0, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
|
||||
grid2.Add( self.set_bounds, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
grid3 = wxFlexGridSizer( 0, 2, 5, 5 )
|
||||
grid3.Add(minlabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL )
|
||||
grid3.Add( self.min, 0, wxALIGN_LEFT )
|
||||
grid3.Add(maxlabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL )
|
||||
grid3.Add( self.max, 0, wxALIGN_LEFT )
|
||||
grid2.Add(grid3, 0, wxALIGN_LEFT )
|
||||
|
||||
grid2.Add( self.limit_check, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
grid2.Add( 20, 0, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
|
||||
grid2.Add( 20, 0, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
grid2.Add( 20, 0, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
grid2.Add( label, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
grid2.Add( self.target_ctrl, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
boundsbox.Add(grid2, 0, wxALIGN_CENTER|wxEXPAND|wxALL, 5)
|
||||
|
||||
vbox = wxBoxSizer( wxVERTICAL )
|
||||
vbox.AddSpacer(20, 20)
|
||||
vbox.Add( hbox, 0, wxALIGN_LEFT|wxALL, 5)
|
||||
vbox.Add( boundsbox, 0, wxALIGN_LEFT|wxALL, 5 )
|
||||
|
||||
|
||||
outer_box = wxBoxSizer( wxVERTICAL )
|
||||
outer_box.AddSizer( grid, 0, wxALIGN_CENTRE|wxBOTTOM, 20 )
|
||||
outer_box.AddSizer( buttonbox, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
outer_box.Add( vbox, 0, wxALIGN_LEFT|wxALL, 5)
|
||||
|
||||
|
||||
# Turn on mxDateTime option only if we can import the module:
|
||||
@@ -72,23 +118,31 @@ class TestPanel( wxPanel ):
|
||||
self.radioMx.Enable( False )
|
||||
|
||||
|
||||
panel.SetAutoLayout( True )
|
||||
panel.SetSizer( outer_box )
|
||||
outer_box.Fit( panel )
|
||||
panel.Move( (50,50) )
|
||||
self.panel = panel
|
||||
|
||||
self.SetAutoLayout( True )
|
||||
self.SetSizer( outer_box )
|
||||
outer_box.Fit( self )
|
||||
self.SetupScrolling()
|
||||
|
||||
EVT_BUTTON( self, buttonChange.GetId(), self.OnButtonClick )
|
||||
EVT_TIMEUPDATE( self, self.time12.GetId(), self.OnTimeChange )
|
||||
EVT_TIMEUPDATE( self, self.time24.GetId(), self.OnTimeChange )
|
||||
EVT_TIMEUPDATE( self, self.spinless_ctrl.GetId(), self.OnTimeChange )
|
||||
|
||||
EVT_BUTTON( self, buttonChange.GetId(), self.OnButtonClick )
|
||||
|
||||
EVT_CHECKBOX( self, self.set_bounds.GetId(), self.OnBoundsCheck )
|
||||
EVT_CHECKBOX( self, self.limit_check.GetId(), self.SetTargetMinMax )
|
||||
EVT_TIMEUPDATE( self, self.min.GetId(), self.SetTargetMinMax )
|
||||
EVT_TIMEUPDATE( self, self.max.GetId(), self.SetTargetMinMax )
|
||||
EVT_TIMEUPDATE( self, self.target_ctrl.GetId(), self.OnTimeChange )
|
||||
|
||||
|
||||
|
||||
def OnTimeChange( self, event ):
|
||||
timectrl = self.panel.FindWindowById( event.GetId() )
|
||||
self.log.write('%s time = %s\n' % ( timectrl.GetName(), timectrl.GetValue() ) )
|
||||
timectrl = self.FindWindowById( event.GetId() )
|
||||
ib_str = [ " (out of bounds)", "" ]
|
||||
|
||||
self.log.write('%s time = %s%s\n' % ( timectrl.GetName(), timectrl.GetValue(), ib_str[ timectrl.IsInBounds() ] ) )
|
||||
|
||||
|
||||
def OnButtonClick( self, event ):
|
||||
if self.radio12to24.GetValue():
|
||||
@@ -99,16 +153,53 @@ class TestPanel( wxPanel ):
|
||||
|
||||
elif self.radioWx.GetValue():
|
||||
now = wxDateTime_Now()
|
||||
self.time12.SetWxDateTime( now )
|
||||
self.time24.SetWxDateTime( now )
|
||||
self.spinless_ctrl.SetWxDateTime( now )
|
||||
self.time12.SetValue( now )
|
||||
# (demonstrates that G/SetValue returns/takes a wxDateTime)
|
||||
self.time24.SetValue( self.time12.GetValue(as_wxDateTime=True) )
|
||||
|
||||
# (demonstrates that G/SetValue returns/takes a wxTimeSpan)
|
||||
self.spinless_ctrl.SetValue( self.time12.GetValue(as_wxTimeSpan=True) )
|
||||
|
||||
elif self.radioMx.GetValue():
|
||||
from mx import DateTime
|
||||
now = DateTime.now()
|
||||
self.time12.SetMxDateTime( now )
|
||||
self.time24.SetMxDateTime( now )
|
||||
self.spinless_ctrl.SetMxDateTime( now )
|
||||
self.time12.SetValue( now )
|
||||
|
||||
# (demonstrates that G/SetValue returns/takes a DateTime)
|
||||
self.time24.SetValue( self.time12.GetValue(as_mxDateTime=True) )
|
||||
|
||||
# (demonstrates that G/SetValue returns/takes a DateTimeDelta)
|
||||
self.spinless_ctrl.SetValue( self.time12.GetValue(as_mxDateTimeDelta=True) )
|
||||
|
||||
|
||||
def OnBoundsCheck( self, event ):
|
||||
self.min.Enable( self.set_bounds.GetValue() )
|
||||
self.max.Enable( self.set_bounds.GetValue() )
|
||||
self.SetTargetMinMax()
|
||||
|
||||
|
||||
def SetTargetMinMax( self, event=None ):
|
||||
min = max = None
|
||||
|
||||
if self.set_bounds.GetValue():
|
||||
min = self.min.GetWxDateTime()
|
||||
max = self.max.GetWxDateTime()
|
||||
else:
|
||||
min, max = None, None
|
||||
|
||||
cur_min, cur_max = self.target_ctrl.GetBounds()
|
||||
|
||||
if min != cur_min: self.target_ctrl.SetMin( min )
|
||||
if max != cur_max: self.target_ctrl.SetMax( max )
|
||||
|
||||
self.target_ctrl.SetLimited( self.limit_check.GetValue() )
|
||||
|
||||
if min != cur_min or max != cur_max:
|
||||
new_min, new_max = self.target_ctrl.GetBounds()
|
||||
if new_min and new_max:
|
||||
self.log.write( "current min, max: (%s, %s)\n" % ( new_min.FormatTime(), new_max.FormatTime() ) )
|
||||
else:
|
||||
self.log.write( "current min, max: (None, None)\n" )
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@@ -118,93 +209,7 @@ def runTest( frame, nb, log ):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = """<html><body>
|
||||
<P>
|
||||
<B>wxTimeCtrl</B> provides a multi-cell control that allows manipulation of a time
|
||||
value. It supports 12 or 24 hour format, and you can use wxDateTime or mxDateTime
|
||||
to get/set values from the control.
|
||||
<P>
|
||||
Left/right/tab keys to switch cells within a wxTimeCtrl, and the up/down arrows act
|
||||
like a spin control. wxTimeCtrl also allows for an actual spin button to be attached
|
||||
to the control, so that it acts like the up/down arrow keys.
|
||||
<P>
|
||||
The <B>!</B> or <B>c</B> key sets the value of the control to <B><I>now.</I></B>
|
||||
<P>
|
||||
Here's the API for wxTimeCtrl:
|
||||
<DL><PRE>
|
||||
<B>wxTimeCtrl</B>(
|
||||
parent, id = -1,
|
||||
<B>value</B> = '12:00:00 AM',
|
||||
pos = wxDefaultPosition,
|
||||
size = wxDefaultSize,
|
||||
<B>fmt24hr</B> = False,
|
||||
<B>spinButton</B> = None,
|
||||
<B>style</B> = wxTE_PROCESS_TAB,
|
||||
name = "time")
|
||||
</PRE>
|
||||
<UL>
|
||||
<DT><B>value</B>
|
||||
<DD>If no initial value is set, the default will be midnight; if an illegal string
|
||||
is specified, a ValueError will result. (You can always later set the initial time
|
||||
with SetValue() after instantiation of the control.)
|
||||
<DL><B>size</B>
|
||||
<DD>The size of the control will be automatically adjusted for 12/24 hour format
|
||||
if wxDefaultSize is specified.
|
||||
<BR>
|
||||
<DT><B>fmt24hr</B>
|
||||
<DD>If True, control will display time in 24 hour time format; if False, it will
|
||||
use 12 hour AM/PM format. SetValue() will adjust values accordingly for the
|
||||
control, based on the format specified.
|
||||
<BR>
|
||||
<DT><B>spinButton</B>
|
||||
<DD>If specified, this button's events will be bound to the behavior of the
|
||||
wxTimeCtrl, working like up/down cursor key events. (See BindSpinButton.)
|
||||
<BR>
|
||||
<DT><B>style</B>
|
||||
<DD>By default, wxTimeCtrl will process TAB events, by allowing tab to the
|
||||
different cells within the control.
|
||||
</DL>
|
||||
</UL>
|
||||
<BR>
|
||||
<BR>
|
||||
<DT><B>SetValue(time_string)</B>
|
||||
<DD>Sets the value of the control to a particular time, given a valid time string;
|
||||
raises ValueError on invalid value
|
||||
<BR>
|
||||
<DT><B>GetValue()</B>
|
||||
<DD>Retrieves the string value of the time from the control
|
||||
<BR>
|
||||
<DT><B>SetWxDateTime(wxDateTime)</B>
|
||||
<DD>Uses the time portion of a wxDateTime to construct a value for the control.
|
||||
<BR>
|
||||
<DT><B>GetWxDateTime()</B>
|
||||
<DD>Retrieves the value of the control, and applies it to the wxDateTimeFromHMS()
|
||||
constructor, and returns the resulting value. (This returns the date portion as
|
||||
"today".)
|
||||
<BR>
|
||||
<DT><B>SetMxDateTime(mxDateTime)</B>
|
||||
<DD>Uses the time portion of an mxDateTime to construct a value for the control.
|
||||
<EM>NOTE:</EM> This imports mx.DateTime at runtime only if this or the Get function
|
||||
is called.
|
||||
<BR>
|
||||
<DT><B>GetMxDateTime()</B>
|
||||
<DD>Retrieves the value of the control and applies it to the DateTime.Time()
|
||||
constructor, and returns the resulting value. (mxDateTime is smart enough to
|
||||
know this is just a time value.)
|
||||
<BR>
|
||||
<DT><B>BindSpinButton(wxSpinBtton)</B>
|
||||
<DD>Binds an externally created spin button to the control, so that up/down spin
|
||||
events change the active cell or selection in the control (in addition to the
|
||||
up/down cursor keys.) (This is primarily to allow you to create a "standard"
|
||||
interface to time controls, as seen in Windows.)
|
||||
<BR>
|
||||
<DT><B>EVT_TIMEUPDATE(win, id, func)</B>
|
||||
<DD>func is fired whenever the value of the control changes.
|
||||
</DL>
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
overview = overviewdoc
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
|
@@ -71,14 +71,6 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
The wxTimer class allows you to execute code at specified intervals.
|
||||
|
||||
@@ -87,8 +79,7 @@ The wxTimer class allows you to execute code at specified intervals.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -48,3 +48,12 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -57,12 +57,12 @@ class TestToolBar(wxFrame):
|
||||
EVT_TOOL_RCLICKED(self, -1, self.OnToolRClick) # Match all
|
||||
EVT_TIMER(self, -1, self.OnClearSB)
|
||||
|
||||
if wxPlatform != "__WXMAC__":
|
||||
tb.AddSeparator()
|
||||
cbID = wxNewId()
|
||||
tb.AddControl(wxComboBox(tb, cbID, "", choices=["", "This", "is a", "wxComboBox"],
|
||||
size=(150,-1), style=wxCB_DROPDOWN))
|
||||
EVT_COMBOBOX(self, cbID, self.OnCombo)
|
||||
tb.AddSeparator()
|
||||
cbID = wxNewId()
|
||||
tb.AddControl(wxComboBox(tb, cbID, "", choices=["", "This", "is a", "wxComboBox"],
|
||||
size=(150,-1), style=wxCB_DROPDOWN))
|
||||
EVT_COMBOBOX(self, cbID, self.OnCombo)
|
||||
tb.AddControl(wxTextCtrl(tb, -1, "Toolbar controls!!", size=(150, -1)))
|
||||
|
||||
tb.Realize()
|
||||
|
||||
|
@@ -167,7 +167,7 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
event.Skip()
|
||||
|
||||
|
||||
def OnActivate(self, evt):
|
||||
def OnActivate(self, event):
|
||||
self.log.WriteText("OnActivate: %s\n" % self.tree.GetItemText(self.item))
|
||||
|
||||
|
||||
|
103
wxPython/demo/wxTreeListCtrl.py
Normal file
103
wxPython/demo/wxTreeListCtrl.py
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.gizmos import wxTreeListCtrl
|
||||
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
|
||||
self.tree = wxTreeListCtrl(self, -1, style = wxTR_DEFAULT_STYLE
|
||||
#| wxTR_ROW_LINES
|
||||
#| wxTR_NO_LINES | wxTR_TWIST_BUTTONS
|
||||
)
|
||||
isz = (16,16)
|
||||
il = wxImageList(isz[0], isz[1])
|
||||
fldridx = il.Add(wxArtProvider_GetBitmap(wxART_FOLDER, wxART_OTHER, isz))
|
||||
fldropenidx = il.Add(wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_OTHER, isz))
|
||||
fileidx = il.Add(wxArtProvider_GetBitmap(wxART_REPORT_VIEW, wxART_OTHER, isz))
|
||||
smileidx = il.Add(images.getSmilesBitmap())
|
||||
|
||||
self.tree.SetImageList(il)
|
||||
self.il = il
|
||||
|
||||
# create some columns
|
||||
self.tree.AddColumn("Main column")
|
||||
self.tree.AddColumn("Column 1")
|
||||
self.tree.AddColumn("Column 2")
|
||||
self.tree.SetMainColumn(0) # the one with the tree in it...
|
||||
self.tree.SetColumnWidth(0, 175)
|
||||
|
||||
|
||||
self.root = self.tree.AddRoot("The Root Item")
|
||||
self.tree.SetItemText(self.root, "col 1 root", 1)
|
||||
self.tree.SetItemText(self.root, "col 2 root", 2)
|
||||
self.tree.SetItemImage(self.root, fldridx, which = wxTreeItemIcon_Normal)
|
||||
self.tree.SetItemImage(self.root, fldropenidx, which = wxTreeItemIcon_Expanded)
|
||||
|
||||
|
||||
for x in range(15):
|
||||
txt = "Item %d" % x
|
||||
child = self.tree.AppendItem(self.root, txt)
|
||||
self.tree.SetItemText(child, txt + "(c1)", 1)
|
||||
self.tree.SetItemText(child, txt + "(c2)", 2)
|
||||
self.tree.SetItemImage(child, fldridx, which = wxTreeItemIcon_Normal)
|
||||
self.tree.SetItemImage(child, fldropenidx, which = wxTreeItemIcon_Expanded)
|
||||
|
||||
for y in range(5):
|
||||
txt = "item %d-%s" % (x, chr(ord("a")+y))
|
||||
last = self.tree.AppendItem(child, txt)
|
||||
self.tree.SetItemText(last, txt + "(c1)", 1)
|
||||
self.tree.SetItemText(last, txt + "(c2)", 2)
|
||||
self.tree.SetItemImage(last, fldridx, which = wxTreeItemIcon_Normal)
|
||||
self.tree.SetItemImage(last, fldropenidx, which = wxTreeItemIcon_Expanded)
|
||||
|
||||
for z in range(5):
|
||||
txt = "item %d-%s-%d" % (x, chr(ord("a")+y), z)
|
||||
item = self.tree.AppendItem(last, txt)
|
||||
self.tree.SetItemText(item, txt + "(c1)", 1)
|
||||
self.tree.SetItemText(item, txt + "(c2)", 2)
|
||||
self.tree.SetItemImage(item, fileidx, which = wxTreeItemIcon_Normal)
|
||||
self.tree.SetItemImage(item, smileidx, which = wxTreeItemIcon_Selected)
|
||||
|
||||
|
||||
self.tree.Expand(self.root)
|
||||
|
||||
|
||||
def OnSize(self, evt):
|
||||
self.tree.SetSize(self.GetSize())
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>wxTreeListCtrl</center></h2>
|
||||
|
||||
The wxTreeListCtrl is essentially a wxTreeCtrl with extra columns,
|
||||
such that the look is similar to a wxListCtrl.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#raw_input("Press enter...")
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user