This commit was manufactured by cvs2svn to create tag 'WX_2_4_1'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WX_2_4_1@21086 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2003-06-12 22:55:41 +00:00
parent 00fd036c18
commit c44e198b19
2863 changed files with 236967 additions and 114090 deletions

View File

@@ -1,6 +1,9 @@
*.pyc
.DS_Store
._demo.py
.emacs.desktop
.gdb_history
.setup.sh
b.bat
hangman_dict.txt
mimetypes_wdr

View File

@@ -1,12 +1,12 @@
import sys, string
import sys
from wxPython.wx import *
from wxPython.html import *
import wxPython.lib.wxpTag
import wx
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))
py_version = string.split(sys.version)[0]
html.SetPage(self.text % (wx.__version__, py_version))
btn = html.FindWindowById(wxID_OK)
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_STRING, py_version))
btn = html.FindWindowById(wx.ID_OK)
btn.SetDefault()
ir = html.GetInternalRepresentation()
html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) )
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()

View File

@@ -62,7 +62,7 @@ class TestPanel(wxPanel):
sizer.Add(btnSizer, 0, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
EVT_WINDOW_DESTROY(self, self.OnDestroy)
@@ -121,7 +121,7 @@ if __name__ == '__main__':
app = wxPySimpleApp()
frame = TestFrame()
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -101,12 +101,18 @@ class TestPanel(wxWindow):
self.location.Append(self.current)
self.SetSizer(sizer)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
EVT_SIZE(self, self.OnSize)
EVT_WINDOW_DESTROY(self, self.OnDestroy)
def ShutdownDemo(self):
# put the frame title back
if self.frame:
self.frame.SetTitle(self.titleBase)
def OnDestroy(self, evt):
if self.ie:
self.ie.Cleanup()
@@ -224,7 +230,7 @@ if __name__ == '__main__':
app = wxPySimpleApp()
frame = TestFrame()
frame.Show(true)
frame.Show(True)
app.MainLoop()

View 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])])

View File

@@ -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])])

View File

@@ -18,7 +18,6 @@
from wxPython.wx import *
from wxPython.lib.colourselect import *
import string
#----------------------------------------------------------------------------
@@ -26,7 +25,7 @@ class TestColourSelect(wxPanel):
def __init__(self, parent, log):
self.log = log
wxPanel.__init__(self, parent, -1)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
mainSizer = wxBoxSizer(wxVERTICAL)
self.SetSizer(mainSizer)
t = wxStaticText(self, -1,
@@ -86,7 +85,7 @@ class TestColourSelect(wxPanel):
colour = button.GetColour() # get the colour selection button result
result.append(name + ": " + str(colour)) # create string list for easy viewing of results
out_result = string.joinfields(result, ', ')
out_result = ', '.join(result)
self.log.WriteText("Colour Results: " + out_result + "\n")
#---------------------------------------------------------------------------

View File

@@ -53,7 +53,7 @@ class TestPanel(wxPanel):
border = wxBoxSizer(wxVERTICAL)
border.Add(sizer, 0, wxALL, 25)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(border)
self.Layout()
@@ -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])])

View File

@@ -124,7 +124,8 @@ class DoodleDropTarget(wxPyDropTarget):
self.dv = window
# specify the type of data we will accept
self.data = wxCustomDataObject(wxCustomDataFormat("DoodleLines"))
self.df = wxCustomDataFormat("DoodleLines")
self.data = wxCustomDataObject(self.df)
self.SetDataObject(self.data)
@@ -138,7 +139,7 @@ class DoodleDropTarget(wxPyDropTarget):
def OnDrop(self, x, y):
self.log.WriteText("OnDrop: %d %d\n" % (x, y))
return true
return True
def OnDragOver(self, x, y, d):
#self.log.WriteText("OnDragOver: %d, %d, %d\n" % (x, y, d))
@@ -153,7 +154,7 @@ class DoodleDropTarget(wxPyDropTarget):
# Called when OnDrop returns true. We need to get the data and
# Called when OnDrop returns True. We need to get the data and
# do something with it.
def OnData(self, x, y, d):
self.log.WriteText("OnData: %d, %d, %d\n" % (x, y, d))
@@ -205,7 +206,7 @@ class CustomDnDPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, false))
self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, False))
# Make the controls
text1 = wxStaticText(self, -1,
@@ -217,9 +218,9 @@ class CustomDnDPanel(wxPanel):
)
rb1 = wxRadioButton(self, -1, "Draw", style=wxRB_GROUP)
rb1.SetValue(true)
rb1.SetValue(True)
rb2 = wxRadioButton(self, -1, "Drag")
rb2.SetValue(false)
rb2.SetValue(False)
text2 = wxStaticText(self, -1,
"The lower window is accepting a\n"
@@ -249,7 +250,7 @@ class CustomDnDPanel(wxPanel):
sizer.Add(dndsizer, 1, wxEXPAND)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(sizer)
# Events
@@ -269,12 +270,12 @@ class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
sizer = wxBoxSizer(wxVERTICAL)
msg = "Custom Drag-And-Drop"
text = wxStaticText(self, -1, "", style=wxALIGN_CENTRE)
text.SetFont(wxFont(24, wxSWISS, wxNORMAL, wxBOLD, false))
text.SetFont(wxFont(24, wxSWISS, wxNORMAL, wxBOLD, False))
text.SetLabel(msg)
w,h = text.GetTextExtent(msg)
text.SetSize(wxSize(w,h+1))
@@ -303,8 +304,9 @@ if __name__ == '__main__':
class TestApp(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
self.MakeFrame()
return true
return True
def MakeFrame(self, event=None):
frame = wxFrame(None, -1, "Custom Drag and Drop", size=(550,400))
@@ -315,7 +317,7 @@ if __name__ == '__main__':
frame.SetMenuBar(mb)
EVT_MENU(frame, 6543, self.MakeFrame)
panel = TestPanel(frame, DummyLog())
frame.Show(true)
frame.Show(True)
self.SetTopWindow(frame)
@@ -326,21 +328,20 @@ if __name__ == '__main__':
#----------------------------------------------------------------------
overview = """<html><body>
This demo shows Drag and Drop using a custom data type and a custom
data object. A type called "DoodleLines" is created and a Python
Pickle of a list is actually transfered in the drag and drop
opperation.
A second data object is also created containing a bitmap of the image
and is made available to any drop target that accepts bitmaps, such as
MS Word.
overview = """\
This demo shows Drag and Drop using a custom data type and a custom data object. A type called "DoodleLines" is created and a Python Pickle of a list is actually transfered in the drag and drop opperation.
A second data object is also created containing a bitmap of the image and is made available to any drop target that accepts bitmaps, such as MS Word.
The two data objects are combined in a wxDataObjectComposite and the rest is handled by the framework.
The two data objects are combined in a wxDataObjectComposite and the
rest is handled by the framework.
</body></html>
"""

View File

@@ -88,13 +88,13 @@ if __name__ == "__main__":
# Create an instance of our customized Frame class
frame = MyFrame(None, -1, "This is a test")
frame.Show(true)
frame.Show(True)
# Tell wxWindows that this is our main window
self.SetTopWindow(frame)
# Return a success flag
return true
return True
app = MyApp(0) # Create an instance of the application class
@@ -107,7 +107,7 @@ if __name__ == "__main__":
def runTest(frame, nb, log):
win = MyFrame(frame, -1, "This is a test")
frame.otherWin = win
win.Show(true)
win.Show(True)
overview = """\

View File

@@ -8,7 +8,7 @@ class ClipTextPanel(wxPanel):
wxPanel.__init__(self, parent, -1)
self.log = log
#self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, false))
#self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, False))
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(wxStaticText(self, -1,
@@ -28,7 +28,7 @@ class ClipTextPanel(wxPanel):
EVT_BUTTON(self, 6051, self.OnPaste)
EVT_BUTTON(self, 6052, self.OnCopyBitmap)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(sizer)
@@ -86,7 +86,7 @@ class OtherDropTarget(wxPyDropTarget):
def OnDrop(self, x, y):
self.log.WriteText("OnDrop: %d %d\n" % (x, y))
return true
return True
def OnData(self, x, y, d):
self.log.WriteText("OnData: %d, %d, %d\n" % (x, y, d))
@@ -128,7 +128,7 @@ class FileDropPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
#self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, false))
#self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, False))
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(wxStaticText(self, -1, " \nDrag some files here:"),
@@ -148,7 +148,7 @@ class FileDropPanel(wxPanel):
self.text2.SetDropTarget(dt)
sizer.Add(self.text2, 1, wxEXPAND)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(sizer)
@@ -166,12 +166,12 @@ class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
outsideSizer = wxBoxSizer(wxVERTICAL)
msg = "Clipboard / Drag-And-Drop"
text = wxStaticText(self, -1, "", style=wxALIGN_CENTRE)
text.SetFont(wxFont(24, wxSWISS, wxNORMAL, wxBOLD, false))
text.SetFont(wxFont(24, wxSWISS, wxNORMAL, wxBOLD, False))
text.SetLabel(msg)
w,h = text.GetTextExtent(msg)
text.SetSize(wxSize(w,h+1))
@@ -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])])

View File

@@ -46,6 +46,43 @@ def makeRandomLines(num, w, h):
return pnts
def makeRandomRectangles(num, W, H):
rects = []
for i in range(num):
w = whrandom.randint(10, W/2)
h = whrandom.randint(10, H/2)
x = whrandom.randint(0, W - w)
y = whrandom.randint(0, H - h)
rects.append( (x, y, w, h) )
return rects
def makeRandomText(num):
Np = 8 # number of charcters in text
text = []
for i in range(num):
word = []
for i in range(Np):
c = chr( whrandom.randint(48, 122) )
word.append( c )
text.append( "".join(word) )
return text
def makeRandomPolygons(num, W, H):
Np = 8 # number of points per polygon
polys = []
for i in range(num):
poly = []
for i in range(Np):
x = whrandom.randint(0, W)
y = whrandom.randint(0, H)
poly.append( (x,y) )
polys.append( poly )
return polys
def makeRandomPens(num, cache):
pens = []
for i in range(num):
@@ -57,62 +94,278 @@ def makeRandomPens(num, cache):
return pens
class TestPanel(wxPanel):
def __init__(self, parent, size, log):
wxPanel.__init__(self, parent, -1, size=size)
def makeRandomBrushes(num, cache):
brushes = []
for i in range(num):
c = whrandom.choice(colours)
if not cache.has_key(c):
cache[c] = wxBrush(c)
brushes.append( cache[c] )
return brushes
def makeRandomColors(num):
colors = []
for i in range(num):
c = whrandom.choice(colours)
colors.append(wxNamedColor(c))
return colors
pencache = {}
brushcache = {}
points = None
lines = None
rectangles = None
polygons = None
text = None
pens = None
brushes = None
colors1 = None
colors2 = None
def Init(w, h, n):
global pencache
global brushcache
global points
global lines
global rectangles
global polygons
global text
global pens
global brushes
global colors1
global colors2
# make some lists of random shapes
points = makeRandomPoints(n, w, h)
try:
import Numeric
Apoints = Numeric.array(points)
except:
pass
lines = makeRandomLines(n, w, h)
rectangles = makeRandomRectangles(n, w, h)
polygons = makeRandomPolygons(n, w, h)
text = makeRandomText(n)
# make some random pens and brushes
pens = makeRandomPens(n, pencache)
brushes = makeRandomBrushes(n, brushcache)
# make some random color lists
colors1 = makeRandomColors(n)
colors2 = makeRandomColors(n)
def TestPoints(dc,log):
dc.BeginDrawing()
start = time.time()
dc.SetPen(wxPen("BLACK", 4))
dc.DrawPointList(points)
dc.DrawPointList(points, wxPen("RED", 2))
dc.DrawPointList(points, pens)
dc.EndDrawing()
log.write("DrawTime: %s seconds with DrawPointList\n" % (time.time() - start))
def TestArrayPoints(dc,log):
try:
import Numeric
dc.BeginDrawing()
start = time.time()
dc.SetPen(wxPen("BLACK", 1))
for i in range(1):
dc.DrawPointList(Apoints)
#dc.DrawPointList(Apoints, wxPen("RED", 2))
#dc.DrawPointList(Apoints, pens)
dc.EndDrawing()
log.write("DrawTime: %s seconds with DrawPointList an Numpy Array\n" % (time.time() - start))
except ImportError:
log.write("Couldn't import Numeric")
pass
def TestLines(dc,log):
dc.BeginDrawing()
start = time.time()
dc.SetPen(wxPen("BLACK", 2))
dc.DrawLineList(lines)
dc.DrawLineList(lines, wxPen("RED", 2))
dc.DrawLineList(lines, pens)
dc.EndDrawing()
log.write("DrawTime: %s seconds with DrawLineList\n" % (time.time() - start))
def TestRectangles(dc,log):
dc.BeginDrawing()
start = time.time()
dc.SetPen( wxPen("BLACK",1) )
dc.SetBrush( wxBrush("RED") )
dc.DrawRectangleList(rectangles)
dc.DrawRectangleList(rectangles,pens)
dc.DrawRectangleList(rectangles,pens[0],brushes)
dc.DrawRectangleList(rectangles,pens,brushes[0])
dc.DrawRectangleList(rectangles,None,brushes)
## for i in range(10):
## #dc.DrawRectangleList(rectangles,pens,brushes)
## dc.DrawRectangleList(rectangles)
dc.EndDrawing()
log.write("DrawTime: %s seconds with DrawRectanglesList\n" % (time.time() - start))
def TestEllipses(dc,log):
dc.BeginDrawing()
start = time.time()
dc.SetPen( wxPen("BLACK",1) )
dc.SetBrush( wxBrush("RED") )
dc.DrawEllipseList(rectangles)
dc.DrawEllipseList(rectangles,pens)
dc.DrawEllipseList(rectangles,pens[0],brushes)
dc.DrawEllipseList(rectangles,pens,brushes[0])
dc.DrawEllipseList(rectangles,None,brushes)
dc.DrawEllipseList(rectangles,pens,brushes)
dc.EndDrawing()
log.write("DrawTime: %s seconds with DrawEllipsesList\n" % (time.time() - start))
def TestRectanglesArray(dc,log):
try:
import Numeric
Apoints = Numeric.array(rectangles)
dc.BeginDrawing()
start = time.time()
dc.SetPen(wxPen("BLACK", 1))
dc.DrawRectangleList(rectangles)
dc.DrawRectangleList(rectangles,pens)
dc.DrawRectangleList(rectangles,pens[0],brushes)
dc.DrawRectangleList(rectangles,pens,brushes[0])
dc.DrawRectangleList(rectangles,None,brushes)
## for i in range(10):
## #dc.DrawRectangleList(rectangles,pens,brushes)
## dc.DrawRectangleList(rectangles)
dc.EndDrawing()
log.write("DrawTime: %s seconds with DrawRectangleList and Numpy Array\n" % (time.time() - start))
except ImportError:
log.write("Couldn't import Numeric")
pass
def TestRectanglesLoop(dc,log):
dc.BeginDrawing()
start = time.time()
dc.DrawRectangleList(rectangles,pens,brushes)
log.write("DrawTime: %s seconds with DrawRectanglesList\n" % (time.time() - start))
start = time.time()
for i in range(len(rectangles)):
dc.SetPen( pens[i] )
dc.SetBrush( brushes[i] )
dc.DrawRectangle(rectangles[i][0],rectangles[i][1],rectangles[i][2],rectangles[i][3])
dc.EndDrawing()
log.write("DrawTime: %s seconds with Python loop\n" % (time.time() - start))
def TestPolygons(dc,log):
dc.BeginDrawing()
start = time.time()
dc.SetPen(wxPen("BLACK", 1))
dc.DrawPolygonList(polygons)
dc.DrawPolygonList(polygons,pens)
dc.DrawPolygonList(polygons,pens[0],brushes)
dc.DrawPolygonList(polygons,pens,brushes[0])
dc.DrawPolygonList(polygons,None,brushes)
log.write("DrawTime: %s seconds with DrawPolygonList\n" % (time.time() - start))
dc.EndDrawing()
def TestText(dc,log):
dc.BeginDrawing()
start = time.time()
# NOTE: you need to set BackgroundMode for the background colors to be used.
dc.SetBackgroundMode(wxSOLID)
foreground = colors1
background = colors2
dc.DrawTextList(text, points, foreground, background)
log.write("DrawTime: %s seconds with DrawTextList\n" % (time.time() - start))
dc.EndDrawing()
class TestNB(wxNotebook):
def __init__(self, parent, id, log):
style = wxNB_BOTTOM
if wxPlatform == "__WXMAC__":
style = 0
wxNotebook.__init__(self, parent, id, style=style)
self.log = log
win = DrawPanel(self, TestEllipses, log)
self.AddPage(win, 'Ellipses')
win = DrawPanel(self, TestText, log)
self.AddPage(win, 'Text')
win = DrawPanel(self, TestPolygons, log)
self.AddPage(win, 'Polygons')
win = DrawPanel(self, TestPoints, log)
self.AddPage(win, 'Points')
win = DrawPanel(self, TestLines, log)
self.AddPage(win, 'Lines')
win = DrawPanel(self, TestRectangles, log)
self.AddPage(win, 'Rectangles')
class DrawPanel(wxPanel):
def __init__(self, parent, drawFun, log):
wxPanel.__init__(self, parent, -1)
self.SetBackgroundColour(wxWHITE)
w = size.width
h = size.height
pencache = {}
# make some lists of random points
self.pnts1 = makeRandomPoints(1000, w, h)
self.pnts2 = makeRandomPoints(1000, w, h)
self.pnts3 = makeRandomPoints(1000, w, h)
self.pens1 = makeRandomPens(1000, pencache)
# and now some lines
self.lines1 = makeRandomLines(500, w, h)
self.lines2 = makeRandomLines(500, w, h)
self.lines3 = makeRandomLines(500, w, h)
self.pens2 = makeRandomPens(500, pencache)
self.log = log
self.drawFun = drawFun
EVT_PAINT(self, self.OnPaint)
def OnPaint(self, evt):
dc = wxPaintDC(self)
dc.BeginDrawing()
start = time.time()
dc.Clear()
self.drawFun(dc,self.log)
dc.SetPen(wxPen("BLACK", 1))
dc.DrawPointList(self.pnts1)
dc.DrawPointList(self.pnts2, wxPen("RED", 2))
dc.DrawPointList(self.pnts3, self.pens1)
dc.SetPen(wxPen("BLACK", 1))
dc.DrawLineList(self.lines1)
dc.DrawLineList(self.lines2, wxPen("RED", 2))
dc.DrawLineList(self.lines3, self.pens2)
dc.EndDrawing()
self.log.write("DrawTime: %s seconds\n" % (time.time() - start))
self.log.write("GetBoundingBox: %s\n" % (dc.GetBoundingBox(), ))
#----------------------------------------------------------------------
def runTest(frame, nb, log):
w = nb.GetClientSize().width
h = nb.GetClientSize().height
if w < 300: w = 300
if h < 300: h = 300
win = wxPanel(nb, -1)
tp = TestPanel(win, wxSize(w, h), log)
def OnPanelSize(evt, tp=tp):
tp.SetSize(evt.GetSize())
EVT_SIZE(win, OnPanelSize)
if w < 600: w = 600
if h < 400: h = 400
Init(w, h, 200)
win = TestNB(nb, -1, log)
return win
#----------------------------------------------------------------------
@@ -136,4 +389,30 @@ drawing routines. Currently they are:
(x1,y1, x2,y2) andd pens is either None, a single pen or a list
of pens.
<pre>
DrawRectangleList(rectangles, pens=None, brushes=None)
</pre>
<pre>
DrawEllipseList(ellipses, pens=None, brushes=None)
</pre>
<pre>
DrawPolygonList(polygons, pens=None, brushes=None)
</pre>
<pre>
DrawTextList(textList, coords, foregrounds = None, backgrounds = None)
</pre>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -14,14 +14,14 @@ ID_BUTTON_wxPyNonFatalErrorDialog = 10004
ID_BUTTON_wxPyFatalErrorDialogWithTraceback = 10005
ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback = 10006
def ErrorDialogsDemoPanelFunc( parent, call_fit = true, set_sizer = true ):
def ErrorDialogsDemoPanelFunc( parent, call_fit = True, set_sizer = True ):
item0 = wxBoxSizer( wxVERTICAL )
item1 = wxStaticText( parent, ID_TEXT, "Please select one of the buttons below for an example using explicit errors...", wxDefaultPosition, wxDefaultSize, 0 )
item0.AddWindow( item1, 0, wxALIGN_CENTRE|wxALL, 5 )
item2 = wxFlexGridSizer( 0, 2, 0, 0 )
item3 = wxButton( parent, ID_BUTTON_wxPyNonFatalError, "wxPyNonFatalError", wxDefaultPosition, wxDefaultSize, 0 )
item2.AddWindow( item3, 0, wxALIGN_CENTRE|wxALL, 5 )
@@ -34,7 +34,7 @@ def ErrorDialogsDemoPanelFunc( parent, call_fit = true, set_sizer = true ):
item0.AddWindow( item5, 0, wxALIGN_CENTRE|wxALL, 5 )
item6 = wxFlexGridSizer( 0, 2, 0, 0 )
item7 = wxButton( parent, ID_BUTTON_wxPyFatalErrorDialog, "wxPyFatalErrorDialog", wxDefaultPosition, wxDefaultSize, 0 )
item6.AddWindow( item7, 0, wxALIGN_CENTRE|wxALL, 5 )
@@ -51,16 +51,16 @@ def ErrorDialogsDemoPanelFunc( parent, call_fit = true, set_sizer = true ):
item0.AddSizer( item6, 0, wxALIGN_CENTRE|wxALL, 5 )
item11 = wxFlexGridSizer( 0, 2, 0, 0 )
item0.AddSizer( item11, 0, wxALIGN_CENTRE|wxALL, 5 )
if set_sizer == true:
parent.SetAutoLayout( true )
if set_sizer == True:
parent.SetAutoLayout( True )
parent.SetSizer( item0 )
if call_fit == true:
if call_fit == True:
item0.Fit( parent )
item0.SetSizeHints( parent )
return item0
# Menu bar functions
@@ -105,8 +105,8 @@ class MyPanel(wxPanel):
EVT_BUTTON(self,
ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback,
self.DoDialog)
EVT_CLOSE(self,self.OnClose)
IndexFromID = {
ID_BUTTON_wxPyFatalErrorDialog: 3,
ID_BUTTON_wxPyFatalErrorDialogWithTraceback: 2,
@@ -138,10 +138,11 @@ class MyPanel(wxPanel):
print "%s.DoDialog(): testing %s..." % (self,sys.stderr)
this_will_generate_a_NameError_exception
def OnClose(self,evt):
def ShutdownDemo(self):
for d in self.dialogs:
d.Destroy ()
self.Destroy ()
d.Destroy()
class MyFrame(wxFrame):
def __init__(self,parent=None):
@@ -158,9 +159,9 @@ class MyFrame(wxFrame):
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame()
frame.Show(true)
frame.Show(True)
self.SetTopWindow(frame)
return true
return True
def runTest(pframe, nb, log):
panel = MyPanel(nb)

View File

@@ -0,0 +1,287 @@
#---------------------------------------------------------------------------
# Name: EventManager.py
# Purpose: A module to demonstrate wxPython.lib.evtmgr.EventManager.
#
# Author: Robb Shecter (robb@acm.org)
#
# Created: 16-December-2002
# Copyright: (c) 2002 by Robb Shecter (robb@acm.org)
# Licence: wxWindows license
#---------------------------------------------------------------------------
from wxPython.wx import *
from wxPython.lib.evtmgr import eventManager
#----------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.log = log
fsize = self.GetFont().GetPointSize()
f1 = wxFont(fsize+0, wxSWISS, wxNORMAL, wxNORMAL)
f2 = wxFont(fsize+2, wxSWISS, wxNORMAL, wxBOLD)
f3 = wxFont(fsize+6, wxSWISS, wxNORMAL, wxBOLD)
title1 = wxStaticText(self, -1, 'EventManager')
title1.SetFont(f3)
txt = """\
This demo shows (1) basic uses and features of the EventManager, as well
as (2) how it helps with a real-world task: creating independent, object-
oriented components."""
message0 = wxStaticText(self, -1, txt)
message0.SetFont(f1)
title2 = wxStaticText(self, -1, 'Event Listeners')
title2.SetFont(f2)
txt = """\
These objects listen to motion events from the target window, using the ability
to register one event with multiple listeners. They also register for mouse events
on themselves to implement toggle-button functionality."""
message1 = wxStaticText(self, -1, txt)
message1.SetFont(f1)
title3 = wxStaticText(self, -1, 'Target Window')
title3.SetFont(f2)
txt = """\
A passive window that's used as an event generator. Move the mouse over it to
send events to the listeners above."""
message2 = wxStaticText(self, -1, txt)
message2.SetFont(f1)
targetPanel = Tile(self, log, bgColor=wxColor(80,10,10), active=0)
buttonPanel = wxPanel(self ,-1)
sizer = wxBoxSizer(wxHORIZONTAL)
target = targetPanel.tile
sizer.Add(0,0,1)
for factor in [0.2, 0.3, 0.4, 0.5, 0.6, 0.7]:
sizer.Add(Tile(buttonPanel, log, factor-0.05, target), 0, wxALIGN_CENTER)
sizer.Add(0,0,1)
sizer.Add(Tile(buttonPanel, log, factor, target), 0, wxALIGN_CENTER)
sizer.Add(0,0,1)
buttonPanel.SetAutoLayout(1)
buttonPanel.SetSizer(sizer)
sizer.Fit(buttonPanel)
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(title1, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 6)
sizer.Add(message0, 0, wxALIGN_CENTER | wxALL, 6)
sizer.Add(title2, 0, wxALIGN_CENTER | wxLEFT | wxTOP | wxRIGHT, 16)
sizer.Add(message1, 0, wxALIGN_CENTER | wxALL, 6)
sizer.Add(buttonPanel, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 16)
sizer.Add(title3, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 16)
sizer.Add(message2, 0, wxALIGN_CENTER | wxALL, 6)
sizer.Add(targetPanel, 2, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 16)
self.SetAutoLayout(1)
self.SetSizer(sizer)
class Tile(wxPanel):
"""
This outer class is responsible for changing
its border color in response to certain mouse
events over its contained 'InnerTile'.
"""
normal = wxColor(150,150,150)
active = wxColor(250,245,245)
hover = wxColor(210,220,210)
def __init__(self, parent, log, factor=1, thingToWatch=None, bgColor=None, active=1, size=(38,38), borderWidth=3):
wxPanel.__init__(self, parent, -1, size=size, style=wxCLIP_CHILDREN)
self.tile = InnerTile(self, log, factor, thingToWatch, bgColor)
self.log = log
sizer = wxBoxSizer(wxHORIZONTAL)
sizer.Add(self.tile, 1, wxEXPAND | wxALL, borderWidth)
self.SetAutoLayout(1)
self.SetSizer(sizer)
self.Layout()
self.SetBackgroundColour(Tile.normal)
if active:
# Register myself for mouse events over self.tile in order to
# create typical button/hyperlink visual effects.
eventManager.Register(self.setHover, EVT_ENTER_WINDOW, self.tile)
eventManager.Register(self.setNormal, EVT_LEAVE_WINDOW, self.tile)
eventManager.Register(self.setActive, EVT_LEFT_DOWN, self.tile)
eventManager.Register(self.setHover, EVT_LEFT_UP, self.tile)
def setHover(self, event):
self.SetBackgroundColour(Tile.hover)
self.Refresh()
def setActive(self, event):
self.SetBackgroundColour(Tile.active)
self.Refresh()
def setNormal(self, event):
self.SetBackgroundColour(Tile.normal)
self.Refresh()
class InnerTile(wxPanel):
IDLE_COLOR = wxColor( 80, 10, 10)
START_COLOR = wxColor(200, 70, 50)
FINAL_COLOR = wxColor( 20, 80,240)
OFF_COLOR = wxColor(185,190,185)
# Some pre-computation.
DELTAS = map(lambda a,b: b-a, START_COLOR.Get(), FINAL_COLOR.Get())
START_COLOR_TUPLE = START_COLOR.Get()
"""
This inner panel changes its color in reaction to mouse
events over the 'thingToWatch'.
"""
def __init__(self, parent, log, factor, thingToWatch=None, bgColor=None):
wxPanel.__init__(self, parent, -1)
self.log=log
if bgColor:
self.SetBackgroundColour(bgColor)
if thingToWatch:
self.factor = factor
self.thingToWatch = thingToWatch
self.state = 0
self.toggleOnOff()
# Watch for the mouse click to enable/disable myself.
eventManager.Register(self.toggleOnOff, EVT_LEFT_UP, self)
def toggleOnOff(self, event=None):
# Implement being on or off by registering and
# de-registering self.makeColor() from the event manager.
if self.state:
eventManager.DeregisterListener(self.makeColor)
else:
eventManager.Register(self.makeColor, EVT_MOTION, self.thingToWatch)
self.state = 1 - self.state
self.resetColor()
def resetColor(self, event=None):
if self.state:
self.setColor(InnerTile.IDLE_COLOR)
else:
self.setColor(InnerTile.OFF_COLOR)
def setColor(self, color):
self.SetBackgroundColour(color)
self.Refresh()
def makeColor(self, mouseEvent):
self.makeColorFromTuple(mouseEvent.GetPositionTuple())
def makeColorFromTuple(self, (x, y)):
MAX = 180.0
scaled = min((x + y) * self.factor, MAX) # In range [0..MAX]
percent = scaled / MAX
r = InnerTile.START_COLOR_TUPLE[0] + (InnerTile.DELTAS[0] * percent)
g = InnerTile.START_COLOR_TUPLE[1] + (InnerTile.DELTAS[1] * percent)
b = InnerTile.START_COLOR_TUPLE[2] + (InnerTile.DELTAS[2] * percent)
self.setColor(wxColor(r,g,b))
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------
overview = """<html><body>
<h2>EventManager</h2>
<p> The goal of the EventManager is to make wxWindows events more
'Pythonic' (ie. object-oriented) and easier to work with, without
impacting performance. It offers these features:
<p>
<ul>
<li> Allows any number of listeners to register for a single
event. (In addition to the standard wxPython feature of a single
listener being able to respond to many events.)
<li> Makes it easy to disconnect and reconnect listeners. This
has the effect of reducing the need for case-based branching in
application code.
<li> Has an object-oriented API. Programmers register to get
events directly from the objects that generate them, instead of
using ID numbers.
</ul>
<h3>Usage</h3>
<p>The EventManager class has three public methods. First get a
reference to it:
<PRE>
from wxPython.lib.evtmgr import eventManager
</PRE>
<p>...and then invoke any of the following methods. These methods are
'safe'; duplicate registrations or de-registrations will have no
effect.
<p><b>Registering a listener:</b>
<PRE>
eventManager.Register(listener, event, event-source)
</PRE>
<p><b>De-registering by window:</b>
<PRE>
eventManager.DeregisterWindow(event-source)
</PRE>
<p><b>De-registering by listener:</b>
<PRE>
eventManager.DeregisterListener(listener)
</PRE>
<p><b>Simple Example:</b>
<PRE>
from wxPython.lib.evtmgr import eventManager
aButton = wxButton(somePanel, -1, 'Click me')
eventManager.Register(self.someMethod, EVT_BUTTON, aButton)
</PRE>
<p> See the demo code as well as the documentation in the source of
<tt>wxPython.lib.evtmgr</tt> for more details.
<p>
by Robb Shecter (robb@acm.org)
</body></html>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -36,6 +36,13 @@ def runTest(frame, nb, log):
import string
overview = string.replace(fancytext.__doc__, "<", "&lt;")
overview = fancytext.__doc__.replace("<", "&lt;")
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -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])])

View File

@@ -3,46 +3,56 @@ from wxPython.wx import *
#----------------------------------------------------------------------
## class MyFontEnumerator(wxFontEnumerator):
## def __init__(self, list):
## wxFontEnumerator.__init__(self)
## self.list = list
## def OnFacename(self, face):
## self.list.append(face)
## return true
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
## list = []
## e = MyFontEnumerator(list)
## e.EnumerateFacenames()
e = wxFontEnumerator()
e.EnumerateFacenames()
list = e.GetFacenames()
list.sort()
wxStaticText(self, -1, "Face names:", (15, 50), (65, 18))
self.lb1 = wxListBox(self, -1, (80, 50), (200, 250),
s1 = wxStaticText(self, -1, "Face names:")
self.lb1 = wxListBox(self, -1, wxDefaultPosition, (200, 250),
list, wxLB_SINGLE)
EVT_LISTBOX(self, self.lb1.GetId(), self.OnSelect)
self.txt = wxStaticText(self, -1, "Sample text...", (285, 50))
row = wxBoxSizer(wxHORIZONTAL)
row.Add(s1, 0, wxALL, 5)
row.Add(self.lb1, 0, wxALL, 5)
row.Add(self.txt, 0, wxALL|wxADJUST_MINSIZE, 5)
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(row, 0, wxALL, 30)
self.SetSizer(sizer)
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()
font = wxFont(28, wxDEFAULT, wxNORMAL, wxNORMAL, false, face)
#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()
@@ -64,9 +74,12 @@ def runTest(frame, nb, log):
overview = """\
wxFontEnumerator enumerates either all available fonts on the system or only the ones with given attributes - either only fixed-width (suited for use in programs such as terminal emulators and the like) or the fonts available in the given encoding.
overview = """<html><body>
wxFontEnumerator enumerates either all available fonts on the system or only
the ones with given attributes - either only fixed-width (suited for use in
programs such as terminal emulators and the like) or the fonts available in
the given encoding.
</body></html>
"""

View File

@@ -28,12 +28,12 @@ class TestPanel(wxPanel):
b = wxGenButton(self, -1, 'disabled')
EVT_BUTTON(self, b.GetId(), self.OnButton)
b.Enable(false)
b.Enable(False)
sizer.Add(b)
b = wxGenButton(self, -1, 'bigger')
EVT_BUTTON(self, b.GetId(), self.OnBiggerButton)
b.SetFont(wxFont(20, wxSWISS, wxNORMAL, wxBOLD, false))
b.SetFont(wxFont(20, wxSWISS, wxNORMAL, wxBOLD, False))
b.SetBezelWidth(5)
###b.SetBestSize()
b.SetBackgroundColour("Navy")
@@ -46,6 +46,12 @@ class TestPanel(wxPanel):
EVT_BUTTON(self, b.GetId(), self.OnButton)
sizer.Add(b)
bmp = images.getTest2Bitmap()
b = wxGenBitmapButton(self, -1, bmp)
EVT_BUTTON(self, b.GetId(), self.OnButton)
sizer.Add(b)
b.Enable(False)
b = wxGenBitmapButton(self, -1, None)
EVT_BUTTON(self, b.GetId(), self.OnButton)
bmp = images.getBulb1Bitmap()
@@ -58,7 +64,6 @@ class TestPanel(wxPanel):
b.SetBitmapSelected(bmp)
b.SetBestSize()
sizer.Add(b)
sizer.Add(10,10)
b = wxGenToggleButton(self, -1, "Toggle Button")
EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
@@ -74,7 +79,7 @@ class TestPanel(wxPanel):
mask = wxMaskColour(bmp, wxBLUE)
bmp.SetMask(mask)
b.SetBitmapSelected(bmp)
b.SetToggle(true)
b.SetToggle(True)
b.SetBestSize()
sizer.Add(b)
@@ -88,7 +93,7 @@ class TestPanel(wxPanel):
mask = wxMaskColour(bmp, wxBLUE)
bmp.SetMask(mask)
b.SetBitmapSelected(bmp)
b.SetUseFocusIndicator(false)
b.SetUseFocusIndicator(False)
b.SetBestSize()
sizer.Add(b)
@@ -128,3 +133,11 @@ def runTest(frame, nb, log):
import wxPython.lib.buttons
overview = wxPython.lib.buttons.__doc__
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -2,6 +2,7 @@
from wxPython.wx import *
from wxPython.grid import *
import string
#---------------------------------------------------------------------------
class MyCellEditor(wxPyGridCellEditor):
"""
@@ -86,16 +87,16 @@ class MyCellEditor(wxPyGridCellEditor):
def EndEdit(self, row, col, grid):
"""
Complete the editing of the current cell. Returns true if the value
Complete the editing of the current cell. Returns True if the value
has changed. If necessary, the control may be destroyed.
*Must Override*
"""
self.log.write("MyCellEditor: EndEdit (%d,%d)\n" % (row, col))
changed = false
changed = False
val = self._tc.GetValue()
if val != self.startValue:
changed = true
changed = True
grid.GetTable().SetValue(row, col, val) # update the table
self.startValue = ''
@@ -115,7 +116,7 @@ class MyCellEditor(wxPyGridCellEditor):
def IsAcceptedKey(self, evt):
"""
Return TRUE to allow the given key to start editing: the base class
Return True to allow the given key to start editing: the base class
version only checks that the event has no modifiers. F2 is special
and will always start the editor.
"""
@@ -143,12 +144,13 @@ class MyCellEditor(wxPyGridCellEditor):
elif key < 256 and key >= 0 and chr(key) in string.printable:
ch = chr(key)
if not evt.ShiftDown():
ch = string.lower(ch)
ch = ch.lower()
if ch is not None:
# For this example, replace the text. Normally we would append it.
#self._tc.AppendText(ch)
self._tc.SetValue(ch)
self._tc.SetInsertionPointEnd()
else:
evt.Skip()
@@ -226,7 +228,7 @@ if __name__ == '__main__':
import sys
app = wxPySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -1,8 +1,6 @@
from wxPython.wx import *
from wxPython.grid import *
import string
#---------------------------------------------------------------------------
class CustomDataTable(wxPyGridTableBase):
@@ -45,7 +43,10 @@ class CustomDataTable(wxPyGridTableBase):
return len(self.data[0])
def IsEmptyCell(self, row, col):
return not self.data[row][col]
try:
return not self.data[row][col]
except IndexError:
return true
# Get/Set values in the table. The Python version of these
# methods can handle any data-type, (as long as the Editor and
@@ -90,11 +91,11 @@ class CustomDataTable(wxPyGridTableBase):
# editor and renderer. This allows you to enforce some type-safety
# in the grid.
def CanGetValueAs(self, row, col, typeName):
colType = string.split(self.dataTypes[col], ':')[0]
colType = self.dataTypes[col].split(':')[0]
if typeName == colType:
return true
else:
return false
return False
def CanSetValueAs(self, row, col, typeName):
return self.CanGetValueAs(row, col, typeName)
@@ -120,7 +121,7 @@ class CustTableGrid(wxGrid):
self.SetRowLabelSize(0)
self.SetMargins(0,0)
self.AutoSizeColumns(false)
self.AutoSizeColumns(False)
EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick)
@@ -138,8 +139,22 @@ class CustTableGrid(wxGrid):
class TestFrame(wxFrame):
def __init__(self, parent, log):
wxFrame.__init__(self, parent, -1, "Custom Table, data driven Grid Demo", size=(640,480))
grid = CustTableGrid(self, log)
p = wxPanel(self, -1, style=0)
grid = CustTableGrid(p, log)
b = wxButton(p, -1, "Another Control...")
b.SetDefault()
EVT_BUTTON(self, b.GetId(), self.OnButton)
EVT_SET_FOCUS(b, self.OnButtonFocus)
bs = wxBoxSizer(wxVERTICAL)
bs.Add(grid, 1, wxGROW|wxALL, 5)
bs.Add(b)
p.SetSizer(bs)
def OnButton(self, evt):
print "button selected"
def OnButtonFocus(self, evt):
print "button focus"
#---------------------------------------------------------------------------

View 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()
#---------------------------------------------------------------------------

View File

@@ -0,0 +1,193 @@
from wxPython.wx import *
from wxPython.grid import *
from wxPython.lib.gridmovers import wxGridColMover, EVT_GRID_COL_MOVE
from wxPython.lib.gridmovers import wxGridRowMover, EVT_GRID_ROW_MOVE
#---------------------------------------------------------------------------
class CustomDataTable(wxPyGridTableBase):
"""
"""
def __init__(self, log):
wxPyGridTableBase.__init__(self)
self.log = log
self.identifiers = ['id','ds','sv','pr','pl','op','fx','ts']
self.rowLabels = ['Row1','Row2','Row3']
self.colLabels = {'id':'ID','ds':'Description','sv':'Severity',
'pr':'Priority','pl':'Platform','op':'Opened?',
'fx':'Fixed?','ts':'Tested?'}
self.data = [{'id':1010,
'ds':"The foo doesn't bar",
'sv':"major",
'pr':1,
'pl':'MSW',
'op':1,
'fx':1,
'ts':1
},
{'id':1011,
'ds':"I've got a wicket in my wocket",
'sv':"wish list",
'pr':2,
'pl':'other',
'op':0,
'fx':0,
'ts':0
},
{'id':1012,
'ds':"Rectangle() returns a triangle",
'sv':"critical",
'pr':5,
'pl':'all',
'op':0,
'fx':0,
'ts':0
}
]
#--------------------------------------------------
# required methods for the wxPyGridTableBase interface
def GetNumberRows(self):
return len(self.data)
def GetNumberCols(self):
return len(self.identifiers)
def IsEmptyCell(self, row, col):
id = self.identifiers[col]
return not self.data[row][id]
def GetValue(self, row, col):
id = self.identifiers[col]
return self.data[row][id]
def SetValue(self, row, col, value):
id = self.identifiers[col]
self.data[row][id] = value
#--------------------------------------------------
# Some optional methods
# Called when the grid needs to display column labels
def GetColLabelValue(self, col):
id = self.identifiers[col]
return self.colLabels[id]
# Called when the grid needs to display row labels
def GetRowLabelValue(self,row):
return self.rowLabels[row]
#--------------------------------------------------
# Methods added for demo purposes.
# The physical moving of the cols/rows is left to the implementer.
# Because of the dynamic nature of a wxGrid the physical moving of
# columns differs from implementation to implementation
# Move the column
def MoveColumn(self,frm,to):
grid = self.GetView()
if grid:
# Move the identifiers
old = self.identifiers[frm]
del self.identifiers[frm]
if to > frm:
self.identifiers.insert(to-1,old)
else:
self.identifiers.insert(to,old)
# Notify the grid
grid.BeginBatch()
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_COLS_DELETED,
frm,1)
grid.ProcessTableMessage(msg)
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_COLS_INSERTED,
to,1)
grid.ProcessTableMessage(msg)
grid.EndBatch()
# Move the row
def MoveRow(self,frm,to):
grid = self.GetView()
if grid:
# Move the rowLabels and data rows
oldLabel = self.rowLabels[frm]
oldData = self.data[frm]
del self.rowLabels[frm]
del self.data[frm]
if to > frm:
self.rowLabels.insert(to-1,oldLabel)
self.data.insert(to-1,oldData)
else:
self.rowLabels.insert(to,oldLabel)
self.data.insert(to,oldData)
# Notify the grid
grid.BeginBatch()
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_ROWS_DELETED,
frm,1)
grid.ProcessTableMessage(msg)
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
to,1)
grid.ProcessTableMessage(msg)
grid.EndBatch()
#---------------------------------------------------------------------------
class DragableGrid(wxGrid):
def __init__(self, parent, log):
wxGrid.__init__(self, parent, -1)
table = CustomDataTable(log)
# The second parameter means that the grid is to take ownership of the
# table and will destroy it when done. Otherwise you would need to keep
# a reference to it and call it's Destroy method later.
self.SetTable(table, True)
# Enable Column moving
wxGridColMover(self)
EVT_GRID_COL_MOVE(self,self.GetId(),self.OnColMove)
# Enable Row moving
wxGridRowMover(self)
EVT_GRID_ROW_MOVE(self,self.GetId(),self.OnRowMove)
# Event method called when a column move needs to take place
def OnColMove(self,evt):
frm = evt.GetMoveColumn() # Column being moved
to = evt.GetBeforeColumn() # Before which column to insert
self.GetTable().MoveColumn(frm,to)
# Event method called when a row move needs to take place
def OnRowMove(self,evt):
frm = evt.GetMoveRow() # Row being moved
to = evt.GetBeforeRow() # Before which row to insert
self.GetTable().MoveRow(frm,to)
#---------------------------------------------------------------------------
class TestFrame(wxFrame):
def __init__(self, parent, log):
wxFrame.__init__(self, parent, -1, "Custom Table, data driven Grid Demo", size=(640,480))
grid = DragableGrid(self, log)
#---------------------------------------------------------------------------
if __name__ == '__main__':
import sys
app = wxPySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(True)
app.MainLoop()
#---------------------------------------------------------------------------

View File

@@ -55,7 +55,7 @@ if __name__ == '__main__':
import sys
app = wxPySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -23,7 +23,7 @@ class HugeTable(wxPyGridTableBase):
return 10000
def IsEmptyCell(self, row, col):
return false
return False
def GetValue(self, row, col):
return str( (row, col) )
@@ -45,7 +45,15 @@ class HugeTableGrid(wxGrid):
# The second parameter means that the grid is to take ownership of the
# table and will destroy it when done. Otherwise you would need to keep
# a reference to it and call it's Destroy method later.
self.SetTable(table, true)
self.SetTable(table, True)
EVT_GRID_CELL_RIGHT_CLICK(self, self.OnRightDown) #added
def OnRightDown(self, event): #added
print "hello"
print self.GetSelectedRows() #added
@@ -56,7 +64,7 @@ class TestFrame(wxFrame):
wxFrame.__init__(self, parent, -1, "Huge (virtual) Table Demo", size=(640,480))
grid = HugeTableGrid(self, log)
grid.SetReadOnly(5,5, true)
grid.SetReadOnly(5,5, True)
#---------------------------------------------------------------------------
@@ -64,7 +72,7 @@ if __name__ == '__main__':
import sys
app = wxPySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -13,8 +13,8 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin):
EVT_IDLE(self, self.OnIdle)
self.CreateGrid(25, 25)
##self.EnableEditing(false)
self.CreateGrid(25, 25) #, wxGrid.wxGridSelectRows)
##self.EnableEditing(False)
# simple cell formatting
self.SetColSize(3, 200)
@@ -26,9 +26,9 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin):
self.SetCellFont(0, 0, wxFont(12, wxROMAN, wxITALIC, wxNORMAL))
self.SetCellTextColour(1, 1, wxRED)
self.SetCellBackgroundColour(2, 2, wxCYAN)
self.SetReadOnly(3, 3, true)
self.SetReadOnly(3, 3, True)
self.SetCellEditor(5, 0, wxGridCellNumberEditor())
self.SetCellEditor(5, 0, wxGridCellNumberEditor(1,1000))
self.SetCellValue(5, 0, "123")
self.SetCellEditor(6, 0, wxGridCellFloatEditor())
self.SetCellValue(6, 0, "123.34")
@@ -53,6 +53,23 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin):
self.SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_BOTTOM)
#self.SetDefaultCellOverflow(False)
#r = wxGridCellAutoWrapStringRenderer()
#self.SetCellRenderer(9, 1, r)
# overflow cells
self.SetCellValue( 9, 1, "This default cell will overflow into neighboring cells, but not if you turn overflow off.");
self.SetCellSize(11, 1, 3, 3);
self.SetCellAlignment(11, 1, wxALIGN_CENTRE, wxALIGN_CENTRE);
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)
EVT_GRID_CELL_RIGHT_CLICK(self, self.OnCellRightClick)
@@ -216,7 +233,7 @@ if __name__ == '__main__':
import sys
app = wxPySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -1,7 +1,7 @@
from wxPython.wx import *
from wxPython.grid import *
import string, random
import random
#---------------------------------------------------------------------------
@@ -60,7 +60,7 @@ editorDemoData = [
('wxGridCellBoolEditor', '1', wxGridCellBoolEditor, ()),
('wxGridCellChoiceEditor', 'one', wxGridCellChoiceEditor, (['one', 'two', 'three', 'four',
'kick', 'Microsoft', 'out the',
'door'], false)),
'door'], False)),
]
@@ -139,15 +139,15 @@ Renderers used together.
attr = wxGridCellAttr()
attr.SetFont(font)
attr.SetBackgroundColour(wxLIGHT_GREY)
attr.SetReadOnly(true)
attr.SetReadOnly(True)
attr.SetAlignment(wxRIGHT, -1)
self.SetColAttr(renCol, attr)
attr.IncRef()
self.SetColAttr(edCol, attr)
# There is a bug in wxGTK for this method...
self.AutoSizeColumns(true)
self.AutoSizeRows(true)
self.AutoSizeColumns(True)
self.AutoSizeRows(True)
EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick)
@@ -174,7 +174,7 @@ if __name__ == '__main__':
import sys
app = wxPySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -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])])

View File

@@ -21,38 +21,38 @@ class AnchorsDemoFrame(wxFrame):
self._init_utils()
self.mainPanel = wxPanel(size = wxSize(320, 160), parent = self, id = wxID_ANCHORSDEMOFRAMEMAINPANEL, name = 'panel1', style = wxTAB_TRAVERSAL | wxCLIP_CHILDREN, pos = wxPoint(0, 0))
self.mainPanel.SetAutoLayout(true)
self.mainPanel.SetAutoLayout(True)
self.okButton = wxButton(label = 'OK', id = wxID_ANCHORSDEMOFRAMEOKBUTTON, parent = self.mainPanel, name = 'okButton', size = wxSize(72, 24), style = 0, pos = wxPoint(240, 128))
self.okButton.SetConstraints(LayoutAnchors(self.okButton, false, false, true, true))
self.okButton.SetConstraints(LayoutAnchors(self.okButton, False, False, True, True))
EVT_BUTTON(self.okButton, wxID_ANCHORSDEMOFRAMEOKBUTTON, self.OnOkButtonButton)
self.backgroundPanel = wxPanel(size = wxSize(304, 80), parent = self.mainPanel, id = wxID_ANCHORSDEMOFRAMEBACKGROUNDPANEL, name = 'backgroundPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN, pos = wxPoint(8, 40))
self.backgroundPanel.SetBackgroundColour(wxColour(255, 255, 255))
self.backgroundPanel.SetConstraints(LayoutAnchors(self.backgroundPanel, true, true, true, true))
self.backgroundPanel.SetConstraints(LayoutAnchors(self.backgroundPanel, True, True, True, True))
self.anchoredPanel = wxPanel(size = wxSize(88, 48), id = wxID_ANCHORSDEMOFRAMEANCHOREDPANEL, parent = self.backgroundPanel, name = 'anchoredPanel', style = wxSIMPLE_BORDER, pos = wxPoint(104, 16))
self.anchoredPanel.SetBackgroundColour(wxColour(0, 0, 222))
self.anchoredPanel.SetConstraints(LayoutAnchors(self.anchoredPanel, false, false, false, false))
self.anchoredPanel.SetConstraints(LayoutAnchors(self.anchoredPanel, False, False, False, False))
self.leftCheckBox = wxCheckBox(label = 'Left', id = wxID_ANCHORSDEMOFRAMELEFTCHECKBOX, parent = self.mainPanel, name = 'leftCheckBox', size = wxSize(40, 16), style = 0, pos = wxPoint(8, 8))
self.leftCheckBox.SetConstraints(LayoutAnchors(self.leftCheckBox, false, true, false, false))
self.leftCheckBox.SetConstraints(LayoutAnchors(self.leftCheckBox, False, True, False, False))
EVT_CHECKBOX(self.leftCheckBox, wxID_ANCHORSDEMOFRAMELEFTCHECKBOX, self.OnCheckboxCheckbox)
self.topCheckBox = wxCheckBox(label = 'Top', id = wxID_ANCHORSDEMOFRAMETOPCHECKBOX, parent = self.mainPanel, name = 'topCheckBox', size = wxSize(40, 16), style = 0, pos = wxPoint(88, 8))
self.topCheckBox.SetConstraints(LayoutAnchors(self.topCheckBox, false, true, false, false))
self.topCheckBox.SetConstraints(LayoutAnchors(self.topCheckBox, False, True, False, False))
EVT_CHECKBOX(self.topCheckBox, wxID_ANCHORSDEMOFRAMETOPCHECKBOX, self.OnCheckboxCheckbox)
self.rightCheckBox = wxCheckBox(label = 'Right', id = wxID_ANCHORSDEMOFRAMERIGHTCHECKBOX, parent = self.mainPanel, name = 'rightCheckBox', size = wxSize(48, 16), style = 0, pos = wxPoint(168, 8))
self.rightCheckBox.SetConstraints(LayoutAnchors(self.rightCheckBox, false, true, false, false))
self.rightCheckBox.SetConstraints(LayoutAnchors(self.rightCheckBox, False, True, False, False))
EVT_CHECKBOX(self.rightCheckBox, wxID_ANCHORSDEMOFRAMERIGHTCHECKBOX, self.OnCheckboxCheckbox)
self.bottomCheckBox = wxCheckBox(label = 'Bottom', id = wxID_ANCHORSDEMOFRAMEBOTTOMCHECKBOX, parent = self.mainPanel, name = 'bottomCheckBox', size = wxSize(56, 16), style = 0, pos = wxPoint(248, 8))
self.bottomCheckBox.SetConstraints(LayoutAnchors(self.bottomCheckBox, false, true, false, false))
self.bottomCheckBox.SetConstraints(LayoutAnchors(self.bottomCheckBox, False, True, False, False))
EVT_CHECKBOX(self.bottomCheckBox, wxID_ANCHORSDEMOFRAMEBOTTOMCHECKBOX, self.OnCheckboxCheckbox)
self.helpStaticText = wxStaticText(label = 'Select anchor options above, then resize window to see the effect', id = wxID_ANCHORSDEMOFRAMEHELPSTATICTEXT, parent = self.mainPanel, name = 'helpStaticText', size = wxSize(224, 24), style = wxST_NO_AUTORESIZE, pos = wxPoint(8, 128))
self.helpStaticText.SetConstraints(LayoutAnchors(self.helpStaticText, true, false, true, true))
self.helpStaticText.SetConstraints(LayoutAnchors(self.helpStaticText, True, False, True, True))
def __init__(self, parent):
self._init_ctrls(parent)
@@ -71,7 +71,7 @@ class AnchorsDemoFrame(wxFrame):
def runTest(frame, nb, log):
win = AnchorsDemoFrame(frame)
frame.otherWin = win
win.Show(true)
win.Show(True)
@@ -136,5 +136,8 @@ overview = """<html><body>
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -8,7 +8,7 @@ class TestLayoutf(wxPanel):
def __init__(self, parent):
wxPanel.__init__(self, parent, -1)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
EVT_BUTTON(self, 100, self.OnButton)
self.panelA = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
@@ -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])])

View File

@@ -3,6 +3,9 @@
from wxPython.wx import *
from wxScrolledWindow import MyCanvas
import images
SHOW_BACKGROUND = 1
#----------------------------------------------------------------------
class MyParentFrame(wxMDIParentFrame):
@@ -24,16 +27,38 @@ class MyParentFrame(wxMDIParentFrame):
EVT_MENU(self, 5000, self.OnNewWindow)
EVT_MENU(self, 5001, self.OnExit)
if SHOW_BACKGROUND:
self.bg_bmp = images.getGridBGBitmap()
EVT_ERASE_BACKGROUND(self.GetClientWindow(), self.OnEraseBackground)
def OnExit(self, evt):
self.Close(true)
self.Close(True)
def OnNewWindow(self, evt):
self.winCount = self.winCount + 1
win = wxMDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
canvas = MyCanvas(win)
win.Show(true)
win.Show(True)
def OnEraseBackground(self, evt):
dc = evt.GetDC()
if not dc:
dc = wxClientDC(self.GetClientWindow())
# tile the background bitmap
sz = self.GetClientSize()
w = self.bg_bmp.GetWidth()
h = self.bg_bmp.GetHeight()
x = 0
while x < sz.width:
y = 0
while y < sz.height:
dc.DrawBitmap(self.bg_bmp, x, y)
y = y + h
x = x + w
#----------------------------------------------------------------------
@@ -43,9 +68,9 @@ if __name__ == '__main__':
def OnInit(self):
wxInitAllImageHandlers()
frame = MyParentFrame()
frame.Show(true)
frame.Show(True)
self.SetTopWindow(frame)
return true
return True
app = MyApp(0)

View File

@@ -44,7 +44,7 @@ class MyParentFrame(wxMDIParentFrame):
win.SetOrientation(wxLAYOUT_HORIZONTAL)
win.SetAlignment(wxLAYOUT_TOP)
win.SetBackgroundColour(wxColour(255, 0, 0))
win.SetSashVisible(wxSASH_BOTTOM, true)
win.SetSashVisible(wxSASH_BOTTOM, True)
self.topWindow = win
@@ -55,7 +55,7 @@ class MyParentFrame(wxMDIParentFrame):
win.SetOrientation(wxLAYOUT_HORIZONTAL)
win.SetAlignment(wxLAYOUT_BOTTOM)
win.SetBackgroundColour(wxColour(0, 0, 255))
win.SetSashVisible(wxSASH_TOP, true)
win.SetSashVisible(wxSASH_TOP, True)
self.bottomWindow = win
@@ -66,7 +66,7 @@ class MyParentFrame(wxMDIParentFrame):
win.SetOrientation(wxLAYOUT_VERTICAL)
win.SetAlignment(wxLAYOUT_LEFT)
win.SetBackgroundColour(wxColour(0, 255, 0))
win.SetSashVisible(wxSASH_RIGHT, TRUE)
win.SetSashVisible(wxSASH_RIGHT, True)
win.SetExtraBorderSize(10)
textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxSUNKEN_BORDER)
@@ -81,7 +81,7 @@ class MyParentFrame(wxMDIParentFrame):
win.SetOrientation(wxLAYOUT_VERTICAL)
win.SetAlignment(wxLAYOUT_LEFT)
win.SetBackgroundColour(wxColour(0, 255, 255))
win.SetSashVisible(wxSASH_RIGHT, TRUE)
win.SetSashVisible(wxSASH_RIGHT, True)
self.leftWindow2 = win
@@ -113,14 +113,14 @@ class MyParentFrame(wxMDIParentFrame):
def OnExit(self, evt):
self.Close(true)
self.Close(True)
def OnNewWindow(self, evt):
self.winCount = self.winCount + 1
win = wxMDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
canvas = MyCanvas(win)
win.Show(true)
win.Show(True)
#----------------------------------------------------------------------
@@ -130,9 +130,9 @@ if __name__ == '__main__':
def OnInit(self):
wxInitAllImageHandlers()
frame = MyParentFrame()
frame.Show(true)
frame.Show(True)
self.SetTopWindow(frame)
return true
return True
app = MyApp(0)

View File

@@ -11,35 +11,30 @@
# Licence: wxWindows license
#----------------------------------------------------------------------------
import sys, os, time, string
from wxPython.wx import *
from wxPython.html import wxHtmlWindow
##from wxPython.stc import *
import sys, os, time
import wx
import wx.html
import images
#---------------------------------------------------------------------------
_treeList = [
# new stuff
('New since last release', [
'RowColSizer',
'Unicode',
'wxFileHistory',
'wxGenericDirCtrl',
'wxImageFromStream',
'wxArtProvider',
'ScrolledPanel',
'wxMenu',
'wxIEHtmlWin',
'wxKeyEvents',
'wxWizard',
'wxXmlResourceHandler',
('Recent Additions', [
'wxScrolledPanel',
'ShapedWindow',
'NewNamespace',
'PopupMenu',
'AnalogClockWindow',
'MaskedEditControls',
'wxTreeListCtrl',
'wxGrid_MegaExample',
]),
# managed windows == things with a caption you can close
# managed windows == things with a (optional) caption you can close
('Base Frames and Dialogs', [
'wxDialog',
'wxFrame',
@@ -73,6 +68,7 @@ _treeList = [
# core controls
('Core Windows/Controls', [
'PopupMenu',
'wxButton',
'wxCheckBox',
'wxCheckListBox',
@@ -81,6 +77,7 @@ _treeList = [
'wxGauge',
'wxGenericDirCtrl',
'wxGrid',
'wxGrid_MegaExample',
'wxListBox',
'wxListCtrl',
'wxListCtrl_virtual',
@@ -88,14 +85,15 @@ _treeList = [
'wxNotebook',
'wxPopupWindow',
'wxRadioBox',
'wxRadioButton',
'wxSashWindow',
'wxSlider',
'wxScrolledWindow',
'wxSplitterWindow',
'wxSlider',
'wxSpinButton',
'wxSpinCtrl',
'wxStaticText',
'wxSplitterWindow',
'wxStaticBitmap',
'wxStaticText',
'wxStatusBar',
'wxTextCtrl',
'wxToggleButton',
@@ -106,29 +104,38 @@ _treeList = [
# controls coming from other librairies
('More Windows/Controls', [
#'wxFloatBar', deprecated
#'wxMVCTree', deprecated
#'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now.
'AnalogClockWindow',
'ColourSelect',
'ContextHelp',
'FancyText',
'FileBrowseButton',
'GenericButtons',
'MaskedEditControls',
'PyShell',
'PyCrust',
'PyCrustWithFilling',
'SplitTree',
'TablePrint',
'Throbber',
'wxCalendar',
'wxCalendarCtrl',
'wxPyColourChooser',
'wxDynamicSashWindow',
'wxEditableListBox',
'wxEditor',
#'wxFloatBar', deprecated
'wxHtmlWindow',
'wxIEHtmlWin',
'wxIntCtrl',
'wxLEDNumberCtrl',
'wxMimeTypesManager',
#'wxMVCTree', deprecated
'wxRightTextCtrl',
'wxMultiSash',
'wxPopupControl',
'wxStyledTextCtrl_1',
'wxStyledTextCtrl_2',
'wxTimeCtrl',
'wxTreeListCtrl',
]),
# How to lay out the controls in a frame/dialog
@@ -136,22 +143,23 @@ _treeList = [
'LayoutAnchors',
'Layoutf',
'RowColSizer',
'ScrolledPanel',
'Sizers',
'wxLayoutConstraints',
'wxScrolledPanel',
'wxXmlResource',
'wxXmlResourceHandler',
]),
# ditto
('Process and Events', [
'EventManager',
'infoframe',
'OOR',
'PythonEvents',
'Threads',
'wxKeyEvents',
'wxProcess',
'wxTimer',
'wxKeyEvents',
]),
# Clipboard and DnD
@@ -162,12 +170,13 @@ _treeList = [
]),
# Images
('Images', [
('Using Images', [
'Throbber',
'wxArtProvider',
'wxDragImage',
'wxImage',
'wxImageFromStream',
'wxMask',
'wxArtProvider',
]),
# Other stuff
@@ -177,6 +186,7 @@ _treeList = [
'DrawXXXList',
'FontEnumerator',
'PrintFramework',
'Throbber',
'Unicode',
'wxFileHistory',
'wxJoystick',
@@ -202,9 +212,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
@@ -212,10 +222,11 @@ class MyLog(wxPyLog):
if self.logTime:
message = time.strftime("%X", time.localtime(timeStamp)) + \
": " + message
self.tc.AppendText(message + '\n')
if self.tc:
self.tc.AppendText(message + '\n')
class MyTP(wxPyTipProvider):
class MyTP(wx.PyTipProvider):
def GetTip(self):
return "This is my tip"
@@ -223,97 +234,116 @@ class MyTP(wxPyTipProvider):
def opj(path):
"""Convert paths to the platform-specific separator"""
return apply(os.path.join, tuple(string.split(path, '/')))
return apply(os.path.join, tuple(path.split('/')))
#---------------------------------------------------------------------------
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 = ""
self.window = None
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)
wx.CallAfter(self.ShowTip)
self.otherWin = None
self.showTip = true
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
# 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)
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()
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!!!')
EVT_MENU(self, helpID, self.OnHelpAbout)
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)
# set the menu accellerator table...
aTable = wxAcceleratorTable([(wxACCEL_ALT, ord('X'), exitID),
(wxACCEL_CTRL, ord('H'), helpID)])
self.SetAcceleratorTable(aTable)
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 = 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:
@@ -325,67 +355,66 @@ 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)
self.txt = wx.TextCtrl(self.nb, -1,
style = wx.TE_MULTILINE|wx.TE_READONLY|
wx.HSCROLL|wx.TE_RICH2|wx.TE_NOHIDESEL)
self.nb.AddPage(self.txt, "Demo Code")
# 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)
self.Show(True)
# add the windows to the splitter and split it.
splitter2.SplitHorizontally(self.nb, self.log)
splitter.SplitVertically(self.tree, splitter2)
splitter2.SplitHorizontally(self.nb, self.log, 450)
splitter.SplitVertically(self.tree, splitter2, 180)
splitter.SetSashPosition(180, true)
splitter.SetMinimumPaneSize(20)
splitter2.SetSashPosition(450, true)
splitter2.SetMinimumPaneSize(20)
@@ -404,14 +433,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):
@@ -420,13 +449,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()
#---------------------------------------------
@@ -453,6 +482,11 @@ class wxPythonDemo(wxFrame):
if self.nb.GetPageCount() == 3:
if self.nb.GetSelection() == 2:
self.nb.SetSelection(0)
# inform the window that it's time to quit if it cares
if self.window is not None:
if hasattr(self.window, "ShutdownDemo"):
self.window.ShutdownDemo()
wx.SafeYield() # in case the page has pending events
self.nb.DeletePage(2)
if itemText == self.overviewText:
@@ -463,22 +497,22 @@ 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:
if self.window is not None:
self.nb.AddPage(self.window, 'Demo')
self.nb.SetSelection(2)
self.nb.Refresh() # without this wxMac has troubles showing the just added page
@@ -507,7 +541,7 @@ class wxPythonDemo(wxFrame):
self.curOverview = text
lead = text[:6]
if lead != '<html>' and lead != '<HTML>':
text = string.join(string.split(text, '\n'), '<br>')
text = '<br>'.join(text.split('\n'))
self.ovr.SetPage(text)
self.nb.SetPageText(0, name)
@@ -516,17 +550,61 @@ class wxPythonDemo(wxFrame):
def OnFileExit(self, *event):
self.Close()
def OnHelpAbout(self, event):
from About import MyAboutBox
about = MyAboutBox(self)
about.ShowModal()
about.Destroy()
def OnHelpFind(self, event):
self.nb.SetSelection(1)
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):
self.nb.SetSelection(1)
end = self.txt.GetLastPosition()
textstring = self.txt.GetRange(0, end).lower()
start = self.txt.GetSelection()[1]
findstring = self.finddata.GetFindString().lower()
loc = textstring.find(findstring, start)
if loc == -1 and start != 0:
# string not found, start at beginning
start = 0
loc = textstring.find(findstring, start)
if loc == -1:
dlg = wx.MessageDialog(self, 'Find String Not Found',
'Find String Not Found in Demo File',
wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
if self.finddlg:
if loc == -1:
self.finddlg.SetFocus()
return
else:
self.finddlg.Destroy()
self.txt.SetSelection(loc, loc + len(findstring))
self.txt.ShowPosition(loc)
def OnFindNext(self, event):
if self.finddata.GetFindString():
self.OnFind(event)
else:
self.OnHelpFind(event)
def OnFindClose(self, event):
event.GetDialog().Destroy()
#---------------------------------------------
def OnCloseWindow(self, event):
self.dying = true
self.dying = True
self.window = None
self.mainmenu = None
if hasattr(self, "tbicon"):
@@ -541,10 +619,6 @@ class wxPythonDemo(wxFrame):
self.window = self.otherWin
self.otherWin = None
if self.showTip:
self.ShowTip()
self.showTip = false
#---------------------------------------------
def ShowTip(self):
@@ -554,9 +628,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) ))
@@ -575,9 +649,9 @@ class wxPythonDemo(wxFrame):
#---------------------------------------------
def OnTaskBarActivate(self, evt):
if self.IsIconized():
self.Iconize(false)
self.Iconize(False)
if not self.IsShown():
self.Show(true)
self.Show(True)
self.Raise()
#---------------------------------------------
@@ -586,7 +660,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)
@@ -596,19 +670,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()
@@ -617,31 +691,36 @@ 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)")
frame.Show(true)
frame.Show()
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
the main frame when it is time to do so.
"""
wxInitAllImageHandlers()
#import locale
#self.locale = wx.Locale(wx.LANGUAGE_FRENCH)
#locale.setlocale(locale.LC_ALL, 'fr')
wx.InitAllImageHandlers()
splash = MySplashScreen()
splash.Show()
return true
return True
@@ -653,7 +732,7 @@ def main():
os.chdir(demoPath)
except:
pass
app = MyApp(wxPlatform == "__WXMAC__")
app = MyApp(wx.Platform == "__WXMAC__")
app.MainLoop()
@@ -662,76 +741,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.
"""
"""
#----------------------------------------------------------------------------

View File

@@ -0,0 +1,534 @@
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.SetMaskParameters(**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)
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])])

View File

@@ -0,0 +1,47 @@
import wx
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])])

View File

@@ -30,7 +30,7 @@ class TestPanel(wxPanel):
sizer.Add(btns, 0, wxEXPAND|wxALL, 15)
self.SetSizer(sizer)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.sizer = sizer # save it for testing later
@@ -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
View 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])])

View File

@@ -33,9 +33,9 @@ class MyPrintout(wxPrintout):
def HasPage(self, page):
self.log.WriteText("wxPrintout.HasPage: %d\n" % page)
if page <= 2:
return true
return True
else:
return false
return False
def GetPageInfo(self):
self.log.WriteText("wxPrintout.GetPageInfo\n")
@@ -82,7 +82,7 @@ class MyPrintout(wxPrintout):
self.canvas.DoDrawing(dc)
dc.DrawText("Page: %d" % page, marginX/2, maxY-marginY)
return true
return True
#----------------------------------------------------------------------
@@ -117,14 +117,14 @@ class TestPrintPanel(wxPanel):
self.box.Add(subbox, 0, wxGROW)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(self.box)
def OnPrintSetup(self, event):
printerDialog = wxPrintDialog(self)
printerDialog.GetPrintDialogData().SetPrintData(self.printData)
printerDialog.GetPrintDialogData().SetSetupDialog(true)
printerDialog.GetPrintDialogData().SetSetupDialog(True)
printerDialog.ShowModal();
self.printData = printerDialog.GetPrintDialogData().GetPrintData()
printerDialog.Destroy()
@@ -144,7 +144,7 @@ class TestPrintPanel(wxPanel):
frame.Initialize()
frame.SetPosition(self.frame.GetPosition())
frame.SetSize(self.frame.GetSize())
frame.Show(true)
frame.Show(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])])

View File

@@ -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

View File

@@ -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
View 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])])

View File

@@ -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])])

View File

@@ -50,7 +50,7 @@ class TestPanel(wxPanel):
sizer.AddSpacer(10,10, pos=(13,1))
self.SetSizer(sizer)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
#----------------------------------------------------------------------
@@ -67,3 +67,9 @@ import wxPython.lib.rcsizer
overview = wxPython.lib.rcsizer.__doc__
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -1,97 +0,0 @@
from wxPython.wx import *
#----------------------------------------------------------------------
text = "one two buckle my shoe three four shut the door five six pick up sticks seven eight lay them straight nine ten big fat hen"
class ScrolledPanel(wxScrolledWindow):
def __init__(self, parent, log):
self.log = log
wxScrolledWindow.__init__(self, parent, -1,
style = wxTAB_TRAVERSAL)
box = wxBoxSizer(wxVERTICAL)
box.Add(wxStaticText(self, -1,
"This sample shows how to make a scrollable data entry \n"
"form by using a wxSizer in a wxScrolledWindow."),
0, wxCENTER|wxALL, 5)
box.Add(wxStaticLine(self, -1), 0, wxEXPAND|wxALL, 5)
fgs = wxFlexGridSizer(cols=2, vgap=4, hgap=4)
fgs.AddGrowableCol(1)
# Add some spacers
fgs.Add(75, 10)
fgs.Add(150, 10)
for word in text.split():
label = wxStaticText(self, -1, word+":")
tc = wxTextCtrl(self, -1, word)
fgs.Add(label, flag=wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL)
fgs.Add(tc, flag=wxEXPAND)
box.Add(fgs, 1)
box.Add(10, 40) # some more empty space at the bottom
self.SetSizer(box)
# The following is all that is needed to integrate the sizer and the
# scrolled window. In this case we will only support vertical scrolling.
self.EnableScrolling(false, true)
self.SetScrollRate(0, 20)
box.SetVirtualSizeHints(self)
EVT_CHILD_FOCUS(self, self.OnChildFocus)
wxCallAfter(self.Scroll, 0, 0) # scroll back to top after initial events
def OnChildFocus(self, evt):
# If the child window that gets the focus is not visible,
# this handler will try to scroll enough to see it. If you
# need to handle horizontal auto-scrolling too then this will
# need adapted.
evt.Skip()
child = evt.GetWindow()
sppu_y = self.GetScrollPixelsPerUnit()[1]
vs_y = self.GetViewStart()[1]
cpos = child.GetPosition()
csz = child.GetSize()
# is it above the top?
if cpos.y < 0:
new_vs = cpos.y / sppu_y
self.Scroll(-1, new_vs)
# is it below the bottom ?
if cpos.y + csz.height > self.GetClientSize().height:
diff = (cpos.y + csz.height - self.GetClientSize().height) / sppu_y
self.Scroll(-1, vs_y + diff + 1)
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = ScrolledPanel(nb, log)
return win
#----------------------------------------------------------------------
overview = """<html><body>
This sample shows how to make a scrollable data entry form by
using a wxSizer in a wxScrolledWindow.
</body></html>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View 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])])

View File

@@ -479,16 +479,16 @@ class TestFrame(wxFrame):
self.SetStatusText("Resize this frame to see how the sizers respond...")
self.sizer.Fit(self)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(self.sizer)
EVT_CLOSE(self, self.OnCloseWindow)
def OnCloseWindow(self, event):
self.MakeModal(false)
self.MakeModal(False)
self.Destroy()
def OnButton(self, event):
self.Close(true)
self.Close(True)
#----------------------------------------------------------------------
@@ -531,8 +531,8 @@ class TestSelectionPanel(wxPanel):
if func:
win = TestFrame(self, title, func)
win.CentreOnParent(wxBOTH)
win.Show(true)
win.MakeModal(true)
win.Show(True)
win.MakeModal(True)
#----------------------------------------------------------------------
@@ -555,12 +555,12 @@ if __name__ == '__main__':
def __init__(self):
wxFrame.__init__(self, None, -1, "Testing...")
self.CreateStatusBar()
mainmenu = wxMenuBar()
menu = wxMenu()
menu.Append(200, 'E&xit', 'Get the heck outta here!')
mainmenu.Append(menu, "&File")
self.SetMenuBar(mainmenu)
self.CreateStatusBar()
mainmenu = wxMenuBar()
menu = wxMenu()
menu.Append(200, 'E&xit', 'Get the heck outta here!')
mainmenu.Append(menu, "&File")
self.SetMenuBar(mainmenu)
EVT_MENU(self, 200, self.OnExit)
self.panel = TestSelectionPanel(self, self)
self.SetSize(wxSize(400, 380))
@@ -570,15 +570,15 @@ if __name__ == '__main__':
self.Destroy()
def OnExit(self, event):
self.Close(true)
self.Close(True)
class TestApp(wxApp):
def OnInit(self):
frame = MainFrame()
frame.Show(true)
frame.Show(True)
self.SetTopWindow(frame)
return true
return True
app = TestApp(0)
app.MainLoop()

View File

@@ -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__
#----------------------------------------------------------------------------

View File

@@ -76,23 +76,26 @@ class TestPanel(wxPanel):
wxNO_BORDER )
valueWindow = TestValueWindow(splitter, -1, style=wxNO_BORDER)
splitter.SplitVertically(tree, valueWindow)
splitter.SetSashPosition(150)
splitter.SplitVertically(tree, valueWindow, 150)
scroller.SetTargetWindow(tree)
scroller.EnableScrolling(FALSE, FALSE)
scroller.EnableScrolling(False, False)
valueWindow.SetTreeCtrl(tree)
tree.SetCompanionWindow(valueWindow)
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(scroller, 1, wxEXPAND|wxALL, 25)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(sizer)
#----------------------------------------------------------------------
def runTest(frame, nb, log):
if wxPlatform == "__WXMAC__":
wxMessageBox("This demo currently fails on the Mac. The problem is being looked into...", "Sorry")
return
win = TestPanel(nb, log)
return win

View File

@@ -31,7 +31,7 @@ class TablePanel(wxPanel):
box.Add(btn, 0, wxALIGN_CENTER|wxALL, 15)
EVT_BUTTON(self, k, self.OnButton)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(box)
def OnButton(self, evt):
@@ -47,11 +47,11 @@ class TablePanel(wxPanel):
data = []
while 1:
text = file.readline()
text = string.strip(text)
text = text.strip()
if not text:
break
list_val = string.splitfields(text,'\t')
list_val = text.split('\t')
data.append(list_val)
file.close()
@@ -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])])

View File

@@ -30,11 +30,11 @@ class CalcBarThread:
self.val = val
def Start(self):
self.keepGoing = self.running = true
self.keepGoing = self.running = True
thread.start_new_thread(self.Run, ())
def Stop(self):
self.keepGoing = false
self.keepGoing = False
def IsRunning(self):
return self.running
@@ -57,7 +57,7 @@ class CalcBarThread:
if self.val < 0: self.val = 0
if self.val > 300: self.val = 300
self.running = false
self.running = False
#----------------------------------------------------------------------
@@ -172,7 +172,7 @@ class TestFrame(wxFrame):
sizer.Add(self.graph, 1, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
sizer.Fit(self)
EVT_UPDATE_BARGRAPH(self, self.OnUpdate)
@@ -194,7 +194,7 @@ class TestFrame(wxFrame):
def OnUpdate(self, evt):
self.graph.SetValue(evt.barNum, evt.value)
self.graph.Refresh(false)
self.graph.Refresh(False)
def OnCloseWindow(self, evt):
@@ -217,7 +217,7 @@ class TestFrame(wxFrame):
def runTest(frame, nb, log):
win = TestFrame(frame, log)
frame.otherWin = win
win.Show(true)
win.Show(True)
return None
#----------------------------------------------------------------------
@@ -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])])

180
wxPython/demo/Throbber.py Normal file
View File

@@ -0,0 +1,180 @@
#
# Throbber.py - Cliff Wells <clifford.wells@attbi.com>
#
from wxPython.wx import *
from wxPython.lib.rcsizer import RowColSizer
from wxPython.lib.throbber import Throbber, __doc__ as docString
import throbImages # this was created using a modified version of img2py
#----------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.log = log
# create the throbbers
self.throbbers = {
'plain': { 'throbber': None,
'text': "Plain throbber." },
'reverse': { 'throbber': None,
'text': "This throbber runs in reverse and faster." },
'autoreverse': { 'throbber': None,
'text': "This throbber switches direction." },
'label': { 'throbber': None,
'text': "With a label." },
'overlay': { 'throbber': None,
'text': "With an overlayed image." },
'overlay+text': { 'throbber': None,
'text': "With a label and an overlayed image." },
}
images = [throbImages.catalog[i].getBitmap()
for i in throbImages.index
if i not in ['eclouds', 'logo']]
self.throbbers['plain']['throbber'] = Throbber(self, -1,
images, size=(36, 36),
frameDelay = 0.1)
self.throbbers['reverse']['throbber'] = Throbber(self, -1, images, #size=(36, 36),
frameDelay = 0.07)
self.throbbers['reverse']['throbber'].Reverse()
self.throbbers['autoreverse']['throbber'] = Throbber(self, -1,
images, #size=(36, 36),
frameDelay = 0.1,
reverse = True)
self.throbbers['autoreverse']['throbber'].sequence.append(0)
self.throbbers['label']['throbber'] = Throbber(self, -1,
images, #size=(36, 36),
frameDelay = 0.1,
label = 'Label')
self.throbbers['label']['throbber'].SetFont(wxFont(pointSize = 10,
family = wxDEFAULT,
style = wxNORMAL,
weight = wxBOLD))
self.throbbers['overlay']['throbber'] = Throbber(self, -1,
images, #size=(36, 36),
frameDelay = 0.1,
overlay = throbImages.catalog['logo'].getBitmap())
self.throbbers['overlay+text']['throbber'] = Throbber(self, -1,
images, #size=(36, 36),
frameDelay = 0.1,
overlay = throbImages.catalog['logo'].getBitmap(),
label = "Python!")
self.throbbers['overlay+text']['throbber'].SetFont(wxFont(pointSize = 8,
family = wxDEFAULT,
style = wxNORMAL,
weight = wxBOLD))
# this throbber is created using a single, composite image
self.otherThrobber = Throbber(self, -1,
throbImages.catalog['eclouds'].getBitmap(), #size=(48, 48),
frameDelay = 0.15,
frames = 12,
frameWidth = 48,
label = "Stop")
EVT_LEFT_DOWN(self.otherThrobber, self.OnClickThrobber)
box = wxBoxSizer(wxVERTICAL)
sizer = RowColSizer()
box.Add(sizer, 1, wxEXPAND|wxALL, 5)
sizer.AddGrowableCol(1)
sizer.Add(self.otherThrobber, row = 0, col = 2, rowspan = 4, flag = wxALIGN_CENTER_VERTICAL)
row = 2
# use a list so we can keep our order
for t in ['plain', 'reverse', 'autoreverse', 'label', 'overlay', 'overlay+text']:
sizer.Add(self.throbbers[t]['throbber'], row = row, col = 0, flag = wxALIGN_CENTER|wxALL, border=2)
sizer.Add(wxStaticText(self, -1, self.throbbers[t]['text']), row = row, col = 1,
flag = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT)
row += 1
# start and stop buttons
startButton = wxButton(self, -1, "Start")
EVT_BUTTON(self, startButton.GetId(), self.OnStartAnimation)
stopButton = wxButton(self, -1, "Stop")
EVT_BUTTON(self, stopButton.GetId(), self.OnStopAnimation)
buttonBox = wxBoxSizer(wxHORIZONTAL)
buttonBox.AddMany([
(startButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5),
(stopButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5),
])
sizer.Add(buttonBox,
row = len(self.throbbers) + 3,
col = 0,
colspan = 3,
flag = wxALIGN_CENTER)
self.SetSizer(box)
self.SetAutoLayout(True)
self.Layout()
sizer.SetSizeHints(self)
sizer.Fit(self)
for t in self.throbbers.keys():
self.throbbers[t]['throbber'].Start()
self.otherThrobber.Start()
self.otherThrobber.Reverse()
EVT_WINDOW_DESTROY(self, self.OnDestroy)
def OnDestroy(self, event):
self.log.write("got destroy event")
event.Skip()
def OnStartAnimation(self, event):
for t in self.throbbers.keys():
self.throbbers[t]['throbber'].Start()
def OnStopAnimation(self, event):
for t in self.throbbers.keys():
self.throbbers[t]['throbber'].Rest()
def OnClickThrobber(self, event):
if self.otherThrobber.Running():
self.otherThrobber.Rest()
self.otherThrobber.SetLabel("Start")
else:
self.otherThrobber.Start()
self.otherThrobber.SetLabel("Stop")
def ShutdownDemo(self):
self.otherThrobber.Rest()
for t in self.throbbers.keys():
self.throbbers[t]['throbber'].Rest()
#----------------------------------------------------------------------
def runTest(frame, nb, log):
if wxPlatform == "__WXMAC__":
wxMessageBox("This demo currently fails on the Mac.",
"Sorry")
return
else:
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------
overview = """<html><body>
<h4><center>Throbber</center></h4>
<p>%s</p>
</body></html>
""" % docString
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -30,12 +30,12 @@ class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
outsideSizer = wxBoxSizer(wxVERTICAL)
msg = "Drag-And-Drop of URLs"
text = wxStaticText(self, -1, "", style=wxALIGN_CENTRE)
text.SetFont(wxFont(24, wxSWISS, wxNORMAL, wxBOLD, false))
text.SetFont(wxFont(24, wxSWISS, wxNORMAL, wxBOLD, False))
text.SetLabel(msg)
w,h = text.GetTextExtent(msg)
text.SetSize(wxSize(w,h+1))
@@ -44,7 +44,7 @@ class TestPanel(wxPanel):
outsideSizer.Add(wxStaticLine(self, -1), 0, wxEXPAND)
outsideSizer.Add(20,20)
self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, false))
self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, False))
inSizer = wxFlexGridSizer(2, 2, 5, 5)
inSizer.AddGrowableCol(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])])

View File

@@ -56,7 +56,7 @@ class TestPanel(wxPanel):
else:
f = self.GetFont()
font = wxFont(14, f.GetFamily(), f.GetStyle(), wxBOLD, false,
font = wxFont(14, f.GetFamily(), f.GetStyle(), wxBOLD, False,
f.GetFaceName(), f.GetEncoding())
self.AddLine(box)
@@ -79,7 +79,7 @@ class TestPanel(wxPanel):
border = wxBoxSizer(wxVERTICAL)
border.Add(box, 1, wxEXPAND|wxALL, 10)
self.SetAutoLayout(true)
self.SetAutoLayout(True)
self.SetSizer(border)
@@ -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])])

View File

@@ -1,5 +1,5 @@
import string, sys
import sys
py2 = sys.version[0] == '2'
@@ -11,9 +11,9 @@ try:
else:
from xml.parsers import pyexpat
parsermodule = pyexpat
haveXML = true
haveXML = True
except ImportError:
haveXML = false
haveXML = False
#----------------------------------------------------------------------
@@ -76,7 +76,7 @@ else:
self.nodeStack = self.nodeStack[:-1]
def CharacterData(self, data ):
if string.strip(data):
if data.strip():
if py2:
data = data.encode()
self.AppendItem(self.nodeStack[-1], data)
@@ -110,3 +110,11 @@ else:
overview = """\
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -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">&lt;wx/wx.h&gt;</font>
<font color="#a020f0">#include </font><font color="#ff00ff">&lt;wx/dnd.h&gt;</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) &amp;&amp; \</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 &amp;&amp; (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&amp; foreground = wxNullColour,
<font color="#2e8b57"><b>const</b></font> wxColour&amp; background = wxNullColour);
<font color="#2e8b57"><b>const</b></font> wxColour&amp; foreground = wxNullColour,
<font color="#2e8b57"><b>const</b></font> wxColour&amp; 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&amp; 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&amp; 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&amp; 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&amp; 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&amp; 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&amp; 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&amp; evt);
<font color="#2e8b57"><b>void</b></font> OnMouseLeftUp(wxMouseEvent&amp; evt);
<font color="#2e8b57"><b>void</b></font> OnMouseRightUp(wxMouseEvent&amp; evt);
<font color="#2e8b57"><b>void</b></font> OnMouseMiddleUp(wxMouseEvent&amp; evt);
<font color="#2e8b57"><b>void</b></font> OnContextMenu(wxContextMenuEvent&amp; evt);
<font color="#2e8b57"><b>void</b></font> OnMouseWheel(wxMouseEvent&amp; evt);
<font color="#2e8b57"><b>void</b></font> OnChar(wxKeyEvent&amp; evt);
@@ -1975,7 +2165,7 @@
<font color="#0000ff">//----------------------------------------------------------------------</font>
<font color="#0000ff">// SWIG can't handle &quot;#if&quot; type of conditionals, onlu &quot;#ifdef&quot;</font>
<font color="#0000ff">// SWIG can't handle &quot;#if&quot; type of conditionals, only &quot;#ifdef&quot;</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>

View File

@@ -2,6 +2,6 @@ Each of the leaf items in the tree is a separate demo. Click and learn!
Use the source Luke!
Many of the demos have some helpful overview text associated with them. Simply click on the first tab in the notebook control after selecting the demo. You can switch back and forth to the demo page as often as you like.
You can also view the source code for each demo by clicking on the second notebook tab.
wxPython now has a company providing commercial support, consulting and training. Go to http://wxpros.com for details.
You shouldn't pee on an electric fence!
Be sure to subscribe to the mail list. Go to http://wxwindows.org/mailman/listinfo/wxpython-users today!
Be sure to subscribe to the mail list. Go to http://wxpython.org/maillist.php today!
The wxPyWiki is a place where wxPython users can help other users, and is a colaborative documentation system. See http://wiki.wxpython.org.

View File

@@ -4,24 +4,30 @@
</head>
<body bgcolor="#00CCFF">
<h2>Mixing wxPython and wxHTML</h2>
The widgets on this page were created dynamically on the fly by a custom
wxTagHandler found in wxPython.lib.wxpTag. You can look at the sources
and doc-string <a href="../../lib/wxpTag.py">here</a>.
The widgets on this page were created dynamically on the fly by a
custom wxTagHandler found in wxPython.lib.wxpTag. You can look at the
sources and doc-string <a href="../../lib/wxpTag.py">here</a>.
<p>
The button below is added to the page like this:
<pre>
&lt;center>&lt;wxp class="wxButton" width="50%">
&lt;param name="label" value="It works!">
&lt;param name="id" value="wxID_OK">
&lt;/wxp>&lt;/center>
</pre>
<hr>
<center>
<wxp class="wxButton" width="50%">
<param name="label" value="It works!">
<param name="id" value="wxID_OK">
</wxp>
</center>
<p>
Notice that the <b>button click</b> event is actually caught by the panel
that contains this window, which then logs it in the window below.

View 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&#64;orbtech.com">pobrien&#64;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 &quot;wx&quot; 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 &quot;wart.&quot; For
example, the following code is rather ugly in that the &quot;wx&quot; 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 &quot;wx&quot; 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">
&quot;&quot;&quot;wx package
Provides a way to drop the wx prefix from wxPython objects.&quot;&quot;&quot;
__author__ = &quot;Patrick K. O'Brien &lt;pobrien&#64;orbtech.com&gt;&quot;
__cvsid__ = &quot;$Id$&quot;
__revision__ = &quot;$Revision$&quot;[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">
&quot;&quot;&quot;Provides a way to drop the wx prefix from wxPython objects.&quot;&quot;&quot;
__author__ = &quot;Patrick K. O'Brien &lt;pobrien&#64;orbtech.com&gt;&quot;
__cvsid__ = &quot;$Id$&quot;
__revision__ = &quot;$Revision$&quot;[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">
&quot;&quot;&quot;Provides a way to drop the wx prefix from wxPython objects.&quot;&quot;&quot;
__author__ = &quot;Patrick K. O'Brien &lt;pobrien&#64;orbtech.com&gt;&quot;
__cvsid__ = &quot;$Id$&quot;
__revision__ = &quot;$Revision$&quot;[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">
&quot;&quot;&quot;Renaming utility.
Provides a way to drop the wx prefix from wxPython objects.&quot;&quot;&quot;
__author__ = &quot;Patrick K. O'Brien &lt;pobrien&#64;orbtech.com&gt;&quot;
__cvsid__ = &quot;$Id$&quot;
__revision__ = &quot;$Revision$&quot;[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 &quot;wx&quot; 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>

View File

@@ -9,52 +9,52 @@ in Python. This is not part of the demo framework.
"""
from wxPython.wx import *
import wx
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):
app.keepGoing = false
app.keepGoing = False
self.Destroy()
def OnIdle(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
@@ -104,12 +104,12 @@ class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(None, -1, "This is a test")
frame.Show(true)
frame.Show(True)
self.SetTopWindow(frame)
self.keepGoing = true
self.keepGoing = True
return true
return True
app = MyApp(0)

View File

@@ -6,7 +6,7 @@ This is a way to save the startup time when running img2py on lots of
files...
"""
import sys, string
import sys
from wxPython.tools import img2py
@@ -60,10 +60,47 @@ 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",
"-a -u -c bmp_source/002.png throbImages.py",
"-a -u -c bmp_source/003.png throbImages.py",
"-a -u -c bmp_source/004.png throbImages.py",
"-a -u -c bmp_source/005.png throbImages.py",
"-a -u -c bmp_source/006.png throbImages.py",
"-a -u -c bmp_source/007.png throbImages.py",
"-a -u -c bmp_source/008.png throbImages.py",
"-a -u -c bmp_source/009.png throbImages.py",
"-a -u -c bmp_source/010.png throbImages.py",
"-a -u -c bmp_source/011.png throbImages.py",
"-a -u -c bmp_source/012.png throbImages.py",
"-a -u -c bmp_source/013.png throbImages.py",
"-a -u -c bmp_source/014.png throbImages.py",
"-a -u -c bmp_source/015.png throbImages.py",
"-a -u -c bmp_source/016.png throbImages.py",
"-a -u -c bmp_source/017.png throbImages.py",
"-a -u -c bmp_source/018.png throbImages.py",
"-a -u -c bmp_source/019.png throbImages.py",
"-a -u -c bmp_source/020.png throbImages.py",
"-a -u -c bmp_source/021.png throbImages.py",
"-a -u -c bmp_source/022.png throbImages.py",
"-a -u -c bmp_source/023.png throbImages.py",
"-a -u -c bmp_source/024.png throbImages.py",
"-a -u -c bmp_source/025.png throbImages.py",
"-a -u -c bmp_source/026.png throbImages.py",
"-a -u -c bmp_source/027.png throbImages.py",
"-a -u -c bmp_source/028.png throbImages.py",
"-a -u -c bmp_source/029.png throbImages.py",
"-a -u -c bmp_source/030.png throbImages.py",
"-a -u -c bmp_source/eclouds.png throbImages.py",
"-a -u -c bmp_source/logo.png throbImages.py",
"-a -u -c bmp_source/rest.png throbImages.py",
]
for line in command_lines:
args = string.split(line)
args = line.split()
img2py.main(args)

View File

@@ -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,string
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 string.lower(m.groups()[0])
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

View File

@@ -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")
@@ -82,14 +82,14 @@ if __name__ == "__main__":
outputWindowClass = wxPyInformationalMessagesFrame
def OnInit(self):
frame = MyFrame(self.stdioWin)
frame.Show(TRUE)
frame.Show(True)
self.SetTopWindow(frame)
if isinstance(sys.stdout,wxPyInformationalMessagesFrame):
sys.stdout.SetParent(frame)
#self.redirectStdio(None)# this is done automatically
# by the MyApp(1) call below
print "Starting.\n",
return true
return True
app = MyApp(1)
app.MainLoop()

View File

@@ -78,7 +78,7 @@ class pyTree(wx.wxTreeCtrl):
wx.wxTreeCtrl.__init__(self, parent, id)
self.root = self.AddRoot(str(root), -1, -1, wx.wxTreeItemData(root))
if dir(root):
self.SetItemHasChildren(self.root, wx.TRUE)
self.SetItemHasChildren(self.root, wx.True)
wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemCollapsed)
wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
@@ -121,7 +121,7 @@ class pyTree(wx.wxTreeCtrl):
new_item = self.AppendItem( item, key, -1, -1,
wx.wxTreeItemData(new_obj) )
if dir(new_obj):
self.SetItemHasChildren(new_item, wx.TRUE)
self.SetItemHasChildren(new_item, wx.True)
def OnItemCollapsed(self, event):
"""
@@ -205,9 +205,9 @@ if __name__ == '__main__':
def OnInit(self):
"""OnInit. Boring, boring, boring!"""
frame = MyFrame()
frame.Show(wx.TRUE)
frame.Show(wx.True)
self.SetTopWindow(frame)
return wx.TRUE
return wx.True
app = MyApp(0)
app.MainLoop()

View File

@@ -19,35 +19,43 @@ on the command line.
import sys, os
from wxPython.wx import *
import wx
#----------------------------------------------------------------------------
class Log:
def WriteText(self, text):
sys.stdout.write(text)
if text[-1:] == '\n':
text = text[:-1]
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()
frame = wxFrame(None, -1, "RunDemo: " + self.name, size=(0,0),
style=wxNO_FULL_REPAINT_ON_RESIZE|wxDEFAULT_FRAME_STYLE)
wx.InitAllImageHandlers()
wx.Log_SetActiveTarget(wx.LogStderr())
#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)
frame.Show(True)
wx.EVT_CLOSE(frame, self.OnCloseFrame)
win = self.demoModule.runTest(frame, frame, Log())
# a window will be returned if the demo does not create
@@ -56,29 +64,37 @@ class RunDemoApp(wxApp):
# so set the frame to a good size for showing stuff
frame.SetSize((640, 480))
win.SetFocus()
self.window = win
else:
# 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.
frame.Destroy()
return true
return True
self.SetTopWindow(frame)
self.frame = frame
#wxLog_SetActiveTarget(wxLogStderr())
#wxLog_SetTraceMask(wxTraceMessages)
return true
#wx.Log_SetActiveTarget(wx.LogStderr())
#wx.Log_SetTraceMask(wx.TraceMessages)
return True
def OnButton(self, evt):
self.frame.Close(true)
self.frame.Close(True)
def OnCloseFrame(self, evt):
if hasattr(self, "window") and hasattr(self.window, "ShutdownDemo"):
self.window.ShutdownDemo()
evt.Skip()
#----------------------------------------------------------------------------

View File

@@ -5,38 +5,38 @@
# structure of any wxPython application.
#----------------------------------------------------------------------
from wxPython.wx import *
import wx
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.SetAutoLayout(True)
panel.Layout()
EVT_BUTTON(self, btn.GetId(), self.OnButton)
wx.EVT_BUTTON(self, btn.GetId(), self.OnButton)
def OnButton(self, evt):
@@ -44,8 +44,9 @@ class MyFrame(wxFrame):
print "OnButton"
self.Close()
app = wxPySimpleApp()
app = wx.PySimpleApp()
frame = MyFrame(None, "Simple wxPython App")
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -1,12 +1,12 @@
from wxPython.wx import *
import wx
#----------------------------------------------------------------------
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)
#----------------------------------------------------------------------

Some files were not shown because too many files have changed in this diff Show More