Merged wxPython 2.4.x to the 2.5 branch (Finally!!!)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19793 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@@ -1,6 +1,9 @@
|
||||
*.pyc
|
||||
.DS_Store
|
||||
._demo.py
|
||||
.emacs.desktop
|
||||
.gdb_history
|
||||
.setup.sh
|
||||
b.bat
|
||||
hangman_dict.txt
|
||||
mimetypes_wdr
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import sys, string
|
||||
import sys
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
@@ -46,12 +46,12 @@ demo item so you can learn how to use the classes yourself.</p>
|
||||
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]
|
||||
py_version = sys.version.split()[0]
|
||||
html.SetPage(self.text % (wx.__version__, py_version))
|
||||
btn = html.FindWindowById(wxID_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)
|
||||
|
||||
|
@@ -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()
|
||||
|
||||
|
||||
|
@@ -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()
|
||||
|
||||
|
||||
|
@@ -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")
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
@@ -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()
|
||||
|
||||
|
@@ -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>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
@@ -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 = """\
|
||||
|
@@ -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))
|
||||
|
@@ -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])])
|
||||
|
||||
|
@@ -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)
|
||||
|
287
wxPython/demo/EventManager.py
Normal 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])])
|
||||
|
@@ -36,6 +36,5 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
import string
|
||||
overview = string.replace(fancytext.__doc__, "<", "<")
|
||||
overview = fancytext.__doc__.replace("<", "<")
|
||||
|
||||
|
@@ -3,44 +3,40 @@ 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, 5)
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
sizer.Add(row, 0, wxALL, 30)
|
||||
self.SetSizer(sizer)
|
||||
self.Layout()
|
||||
|
||||
self.lb1.SetSelection(0)
|
||||
|
||||
|
||||
def OnSelect(self, evt):
|
||||
face = self.lb1.GetStringSelection()
|
||||
font = wxFont(28, wxDEFAULT, wxNORMAL, wxNORMAL, false, face)
|
||||
font = wxFont(28, wxDEFAULT, wxNORMAL, wxNORMAL, False, face)
|
||||
self.txt.SetFont(font)
|
||||
self.txt.SetSize(self.txt.GetBestSize())
|
||||
|
||||
@@ -64,9 +60,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>
|
||||
"""
|
||||
|
||||
|
||||
|
@@ -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])])
|
||||
|
||||
|
@@ -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()
|
||||
|
||||
|
||||
|
@@ -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"
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
193
wxPython/demo/GridDragable.py
Normal 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()
|
||||
|
||||
#---------------------------------------------------------------------------
|
@@ -55,7 +55,7 @@ if __name__ == '__main__':
|
||||
import sys
|
||||
app = wxPySimpleApp()
|
||||
frame = TestFrame(None, sys.stdout)
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
@@ -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()
|
||||
|
||||
|
||||
|
@@ -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,18 @@ 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");
|
||||
|
||||
|
||||
|
||||
# test all the events
|
||||
EVT_GRID_CELL_LEFT_CLICK(self, self.OnCellLeftClick)
|
||||
EVT_GRID_CELL_RIGHT_CLICK(self, self.OnCellRightClick)
|
||||
@@ -216,7 +228,7 @@ if __name__ == '__main__':
|
||||
import sys
|
||||
app = wxPySimpleApp()
|
||||
frame = TestFrame(None, sys.stdout)
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
@@ -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()
|
||||
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -11,7 +11,7 @@
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
import sys, os, time, string
|
||||
import sys, os, time
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import wxHtmlWindow
|
||||
|
||||
@@ -19,27 +19,19 @@ from wxPython.html import wxHtmlWindow
|
||||
|
||||
import images
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
_treeList = [
|
||||
# new stuff
|
||||
('New since last release', [
|
||||
'RowColSizer',
|
||||
'Unicode',
|
||||
'wxFileHistory',
|
||||
'wxGenericDirCtrl',
|
||||
'wxImageFromStream',
|
||||
'wxArtProvider',
|
||||
'ScrolledPanel',
|
||||
'wxMenu',
|
||||
'wxIEHtmlWin',
|
||||
'wxKeyEvents',
|
||||
'wxWizard',
|
||||
'wxXmlResourceHandler',
|
||||
('Recent Additions', [
|
||||
'wxIntCtrl',
|
||||
'wxPyColourChooser',
|
||||
'wxScrolledPanel',
|
||||
]),
|
||||
|
||||
# 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',
|
||||
@@ -88,14 +80,15 @@ _treeList = [
|
||||
'wxNotebook',
|
||||
'wxPopupWindow',
|
||||
'wxRadioBox',
|
||||
'wxRadioButton',
|
||||
'wxSashWindow',
|
||||
'wxSlider',
|
||||
'wxScrolledWindow',
|
||||
'wxSplitterWindow',
|
||||
'wxSlider',
|
||||
'wxSpinButton',
|
||||
'wxSpinCtrl',
|
||||
'wxStaticText',
|
||||
'wxSplitterWindow',
|
||||
'wxStaticBitmap',
|
||||
'wxStaticText',
|
||||
'wxStatusBar',
|
||||
'wxTextCtrl',
|
||||
'wxToggleButton',
|
||||
@@ -106,6 +99,9 @@ _treeList = [
|
||||
|
||||
# controls coming from other librairies
|
||||
('More Windows/Controls', [
|
||||
#'wxFloatBar', deprecated
|
||||
#'wxMVCTree', deprecated
|
||||
#'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now.
|
||||
'ColourSelect',
|
||||
'ContextHelp',
|
||||
'FancyText',
|
||||
@@ -115,20 +111,23 @@ _treeList = [
|
||||
'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',
|
||||
]),
|
||||
|
||||
# How to lay out the controls in a frame/dialog
|
||||
@@ -136,22 +135,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 +162,13 @@ _treeList = [
|
||||
]),
|
||||
|
||||
# Images
|
||||
('Images', [
|
||||
('Using Images', [
|
||||
'Throbber',
|
||||
'wxArtProvider',
|
||||
'wxDragImage',
|
||||
'wxImage',
|
||||
'wxImageFromStream',
|
||||
'wxMask',
|
||||
'wxArtProvider',
|
||||
]),
|
||||
|
||||
# Other stuff
|
||||
@@ -177,6 +178,7 @@ _treeList = [
|
||||
'DrawXXXList',
|
||||
'FontEnumerator',
|
||||
'PrintFramework',
|
||||
'Throbber',
|
||||
'Unicode',
|
||||
'wxFileHistory',
|
||||
'wxJoystick',
|
||||
@@ -212,7 +214,8 @@ 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):
|
||||
@@ -223,7 +226,7 @@ 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('/')))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -237,6 +240,7 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
self.cwd = os.getcwd()
|
||||
self.curOverview = ""
|
||||
self.window = None
|
||||
|
||||
icon = images.getMondrianIcon()
|
||||
self.SetIcon(icon)
|
||||
@@ -250,9 +254,9 @@ class wxPythonDemo(wxFrame):
|
||||
EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
|
||||
EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
|
||||
|
||||
wxCallAfter(self.ShowTip)
|
||||
|
||||
self.otherWin = None
|
||||
self.showTip = true
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
EVT_ICONIZE(self, self.OnIconfiy)
|
||||
@@ -268,8 +272,8 @@ class wxPythonDemo(wxFrame):
|
||||
EVT_ERASE_BACKGROUND(splitter, EmptyHandler)
|
||||
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()
|
||||
@@ -277,6 +281,7 @@ class wxPythonDemo(wxFrame):
|
||||
exitID = wxNewId()
|
||||
menu.Append(exitID, 'E&xit\tAlt-X', 'Get the heck outta here!')
|
||||
EVT_MENU(self, exitID, self.OnFileExit)
|
||||
wxApp_SetMacExitMenuItemId(exitID)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
# Make a Demo menu
|
||||
@@ -293,16 +298,33 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
# Make a Help menu
|
||||
helpID = wxNewId()
|
||||
findID = wxNewId()
|
||||
findnextID = wxNewId()
|
||||
menu = wxMenu()
|
||||
menu.Append(findID, '&Find\tCtrl-F', 'Find in the Demo Code')
|
||||
menu.Append(findnextID, 'Find &Next\tF3', 'Find Next')
|
||||
menu.AppendSeparator()
|
||||
menu.Append(helpID, '&About\tCtrl-H', 'wxPython RULES!!!')
|
||||
wxApp_SetMacAboutMenuItemId(helpID)
|
||||
EVT_MENU(self, helpID, self.OnHelpAbout)
|
||||
EVT_MENU(self, findID, self.OnHelpFind)
|
||||
EVT_MENU(self, findnextID, self.OnFindNext)
|
||||
EVT_COMMAND_FIND(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_CLOSE(self, -1 , self.OnFindClose)
|
||||
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 = wxFindReplaceData()
|
||||
|
||||
if 0:
|
||||
# This is another way to set Accelerators, in addition to
|
||||
# using the '\t<key>' syntax in the menu items.
|
||||
aTable = wxAcceleratorTable([(wxACCEL_ALT, ord('X'), exitID),
|
||||
(wxACCEL_CTRL, ord('H'), helpID),
|
||||
(wxACCEL_CTRL, ord('F'), findID),
|
||||
(wxACCEL_NORMAL, WXK_F3, findnextID)])
|
||||
self.SetAcceleratorTable(aTable)
|
||||
|
||||
|
||||
# Create a TreeCtrl
|
||||
@@ -358,7 +380,8 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
# Set up a TextCtrl on the Demo Code Notebook page
|
||||
self.txt = wxTextCtrl(self.nb, -1,
|
||||
style = wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
|
||||
style = wxTE_MULTILINE|wxTE_READONLY|
|
||||
wxHSCROLL|wxTE_RICH2|wxTE_NOHIDESEL)
|
||||
self.nb.AddPage(self.txt, "Demo Code")
|
||||
|
||||
|
||||
@@ -376,16 +399,14 @@ class wxPythonDemo(wxFrame):
|
||||
#wxLog_SetActiveTarget(wxLogStderr())
|
||||
#wxLog_SetTraceMask(wxTraceMessages)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -453,6 +474,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()
|
||||
wxSafeYield() # in case the page has pending events
|
||||
self.nb.DeletePage(2)
|
||||
|
||||
if itemText == self.overviewText:
|
||||
@@ -478,7 +504,7 @@ class wxPythonDemo(wxFrame):
|
||||
wxSafeYield()
|
||||
|
||||
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 +533,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 +542,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 = wxFindReplaceDialog(self, self.finddata, "Find",
|
||||
wxFR_NOUPDOWN |
|
||||
wxFR_NOMATCHCASE |
|
||||
wxFR_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 = wxMessageDialog(self, 'Find String Not Found',
|
||||
'Find String Not Found in Demo File',
|
||||
wxOK | wxICON_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 +611,6 @@ class wxPythonDemo(wxFrame):
|
||||
self.window = self.otherWin
|
||||
self.otherWin = None
|
||||
|
||||
if self.showTip:
|
||||
self.ShowTip()
|
||||
self.showTip = false
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def ShowTip(self):
|
||||
@@ -575,9 +641,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()
|
||||
|
||||
#---------------------------------------------
|
||||
@@ -628,7 +694,7 @@ class MySplashScreen(wxSplashScreen):
|
||||
|
||||
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...
|
||||
|
||||
|
||||
@@ -638,10 +704,15 @@ class MyApp(wxApp):
|
||||
Create and show the splash screen. It will then create and show
|
||||
the main frame when it is time to do so.
|
||||
"""
|
||||
|
||||
#import locale
|
||||
#self.locale = wxLocale(wxLANGUAGE_FRENCH)
|
||||
#locale.setlocale(locale.LC_ALL, 'fr')
|
||||
|
||||
wxInitAllImageHandlers()
|
||||
splash = MySplashScreen()
|
||||
splash.Show()
|
||||
return true
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
@@ -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])])
|
||||
|
||||
|
@@ -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])])
|
||||
|
@@ -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()
|
||||
|
@@ -170,22 +170,22 @@ class AppStatusBar(wxStatusBar):
|
||||
# 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?)
|
||||
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, ());
|
||||
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);
|
||||
# if the window manager closes the window:
|
||||
EVT_CLOSE(self, self.OnCloseWindow);
|
||||
|
||||
# Now Create the menu bar and items
|
||||
# Now Create the menu bar and items
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
@@ -201,52 +201,52 @@ class AppFrame(wxFrame):
|
||||
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)
|
||||
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')
|
||||
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'
|
||||
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)
|
||||
# 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.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)
|
||||
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)
|
||||
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)
|
||||
@@ -268,44 +268,44 @@ class AppFrame(wxFrame):
|
||||
self.list.SetStringItem(i, 3, article[6])
|
||||
self.url.append(article[1])
|
||||
i = i + 1
|
||||
self.logprint("File retrieved OK.")
|
||||
self.logprint("File retrieved OK.")
|
||||
|
||||
def OnViewRefresh(self, event):
|
||||
self.logprint("Connecting to slashdot... Please wait.");
|
||||
wxYield()
|
||||
self.DoRefresh()
|
||||
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)
|
||||
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")
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewIndex(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewIndex()
|
||||
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)
|
||||
self.view.Show(True)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % (url))
|
||||
os.system(self.BrowserSettings % (url))
|
||||
self.logprint("OK")
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewArticle(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewArticle()
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewArticle()
|
||||
|
||||
def OnBrowserInternal(self, event):
|
||||
if self.mainmenu.Checked(220):
|
||||
@@ -319,28 +319,28 @@ class AppFrame(wxFrame):
|
||||
self.BrowserSettings = dlg.GetValue()
|
||||
|
||||
def OnAbout(self, event):
|
||||
dlg = wxMessageDialog(self, __doc__, "wxSlash", wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
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)
|
||||
(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()
|
||||
@@ -353,9 +353,9 @@ if __name__ == '__main__':
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = AppFrame(None, -1, "Slashdot Breaking News")
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
return True
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
@@ -368,7 +368,7 @@ if __name__ == '__main__':
|
||||
def runTest(frame, nb, log):
|
||||
win = AppFrame(None, -1, "Slashdot Breaking News")
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
win.Show(True)
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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()
|
||||
|
||||
|
@@ -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
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
180
wxPython/demo/Throbber.py
Normal 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])])
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
||||
|
||||
|
@@ -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)
|
||||
|
BIN
wxPython/demo/bmp_source/001.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/002.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/003.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/004.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/005.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
wxPython/demo/bmp_source/006.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/007.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/008.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/009.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/010.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/011.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/012.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/013.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/014.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/015.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/016.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/017.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/018.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/019.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/020.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/021.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/022.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/023.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/024.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/025.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/026.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/027.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/028.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
wxPython/demo/bmp_source/029.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bmp_source/030.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
wxPython/demo/bmp_source/eclouds.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
wxPython/demo/bmp_source/logo.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/rest.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
@@ -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.
|
||||
|
@@ -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>
|
||||
<center><wxp class="wxButton" width="50%">
|
||||
<param name="label" value="It works!">
|
||||
<param name="id" value="wxID_OK">
|
||||
</wxp></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.
|
||||
|
@@ -54,7 +54,7 @@ class MyFrame(wxFrame):
|
||||
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
app.keepGoing = false
|
||||
app.keepGoing = False
|
||||
self.Destroy()
|
||||
|
||||
def OnIdle(self, event):
|
||||
@@ -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)
|
||||
|
@@ -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,46 @@ command_lines = [
|
||||
"-a -u -n WizTest1 bmp_source/wiztest1.bmp images.py",
|
||||
"-a -u -n WizTest2 bmp_source/wiztest2.bmp 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)
|
||||
|
||||
|
@@ -14,7 +14,7 @@ Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)"""
|
||||
|
||||
import random,re,string
|
||||
import random,re
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class WordFetcher:
|
||||
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])
|
||||
if n: return m.groups()[0].lower()
|
||||
return "error"
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ class MyFrame(wxFrame):
|
||||
menubar = wxMenuBar()
|
||||
menubar.Append(menu, "Game")
|
||||
menu = wxMenu()
|
||||
#menu.Append(1010, "Internal", "Use internal dictionary", TRUE)
|
||||
#menu.Append(1010, "Internal", "Use internal dictionary", True)
|
||||
menu.Append(1011, "ASCII File...")
|
||||
urls = [ 'wxPython home', 'http://wxPython.org/',
|
||||
'slashdot.org', 'http://slashdot.org/',
|
||||
@@ -349,7 +349,7 @@ class MyFrame(wxFrame):
|
||||
|
||||
def OnGameDemo(self, event):
|
||||
frame = HangmanDemoFrame(self.wf, self, -1, wxDefaultPosition, self.GetSize())
|
||||
frame.Show(TRUE)
|
||||
frame.Show(True)
|
||||
|
||||
def OnDictFile(self, event):
|
||||
fd = wxFileDialog(self)
|
||||
@@ -433,8 +433,8 @@ class MyApp(wxApp):
|
||||
wf = WordFetcher(defaultfile)
|
||||
frame = MyFrame(None, wf)
|
||||
self.SetTopWindow(frame)
|
||||
frame.Show(TRUE)
|
||||
return TRUE
|
||||
frame.Show(True)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ def runTest(frame, nb, log):
|
||||
wf = WordFetcher(defaultfile)
|
||||
win = MyFrame(frame, wf)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
win.Show(True)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#----------------------------------------------------------------------
|
||||
# This file was generated by C:\projects\wx\wxPython\demo\encode_bitmaps.py
|
||||
# This file was generated by encode_bitmaps.py
|
||||
#
|
||||
from wxPython.wx import wxImageFromStream, wxBitmapFromImage
|
||||
from wxPython.wx import wxEmptyIcon
|
||||
|
@@ -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()
|
||||
|
@@ -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()
|
||||
|
@@ -25,7 +25,9 @@ from wxPython.wx import *
|
||||
|
||||
class Log:
|
||||
def WriteText(self, text):
|
||||
sys.stdout.write(text)
|
||||
if text[-1:] == '\n':
|
||||
text = text[:-1]
|
||||
wxLogMessage(text)
|
||||
write = WriteText
|
||||
|
||||
|
||||
@@ -38,7 +40,9 @@ class RunDemoApp(wxApp):
|
||||
|
||||
def OnInit(self):
|
||||
wxInitAllImageHandlers()
|
||||
frame = wxFrame(None, -1, "RunDemo: " + self.name, size=(0,0),
|
||||
wxLog_SetActiveTarget(wxLogStderr())
|
||||
|
||||
frame = wxFrame(None, -1, "RunDemo: " + self.name, pos=(50,50), size=(0,0),
|
||||
style=wxNO_FULL_REPAINT_ON_RESIZE|wxDEFAULT_FRAME_STYLE)
|
||||
frame.CreateStatusBar()
|
||||
menuBar = wxMenuBar()
|
||||
@@ -47,7 +51,9 @@ class RunDemoApp(wxApp):
|
||||
EVT_MENU(self, 101, self.OnButton)
|
||||
menuBar.Append(menu, "&File")
|
||||
frame.SetMenuBar(menuBar)
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
EVT_CLOSE(frame, self.OnCloseFrame)
|
||||
|
||||
win = self.demoModule.runTest(frame, frame, Log())
|
||||
|
||||
# a window will be returned if the demo does not create
|
||||
@@ -56,6 +62,7 @@ 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
|
||||
@@ -68,17 +75,24 @@ class RunDemoApp(wxApp):
|
||||
# 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
|
||||
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()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
@@ -33,7 +33,7 @@ class MyFrame(wxFrame):
|
||||
sizer.Add(text, 0, wxALL, 10)
|
||||
sizer.Add(btn, 0, wxALL, 10)
|
||||
panel.SetSizer(sizer)
|
||||
panel.SetAutoLayout(true)
|
||||
panel.SetAutoLayout(True)
|
||||
panel.Layout()
|
||||
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnButton)
|
||||
@@ -46,6 +46,6 @@ class MyFrame(wxFrame):
|
||||
|
||||
app = wxPySimpleApp()
|
||||
frame = MyFrame(None, "Simple wxPython App")
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
|
||||
|
4362
wxPython/demo/throbImages.py
Normal file
@@ -59,11 +59,11 @@ class SecondThreadApp(wxApp):
|
||||
catcher = HiddenCatcher()
|
||||
#self.SetTopWindow(catcher)
|
||||
self.catcher =catcher
|
||||
return true
|
||||
return True
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def add_cone():
|
||||
frame = VtkFrame(None, -1, "Cone")
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
import sys, string
|
||||
import sys
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
@@ -43,7 +43,7 @@ class TestHtmlPanel(wxPanel):
|
||||
import About
|
||||
wxPanel.__init__(self, parent, id, size=size)
|
||||
self.html = wxHtmlWindow(self, -1, wxPoint(5,5), wxSize(400, 350))
|
||||
py_version = string.split(sys.version)[0]
|
||||
py_version = sys.version.split()[0]
|
||||
self.html.SetPage(About.MyAboutBox.text % (wx.__version__, py_version))
|
||||
ir = self.html.GetInternalRepresentation()
|
||||
self.html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) )
|
||||
|
@@ -19,20 +19,38 @@ class TestPanel(wxPanel):
|
||||
|
||||
b = wxButton(self, 20, "HELLO AGAIN!", wxPoint(20, 60), wxSize(120, 45))
|
||||
EVT_BUTTON(self, 20, self.OnClick)
|
||||
|
||||
b.SetToolTipString("This is a Hello button...")
|
||||
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
if 0: # a test case for catching wxPyAssertionError
|
||||
|
||||
#wxGetApp().SetAssertMode(wxPYAPP_ASSERT_SUPPRESS)
|
||||
#wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION)
|
||||
#wxGetApp().SetAssertMode(wxPYAPP_ASSERT_DIALOG)
|
||||
#wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION | wxPYAPP_ASSERT_DIALOG)
|
||||
|
||||
try:
|
||||
bmp = wxBitmap("nosuchfile.bmp", wxBITMAP_TYPE_BMP)
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
except wxPyAssertionError:
|
||||
self.log.write("Caught wxPyAssertionError! I will fix the problem.\n")
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
else:
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
|
||||
bmp.SetMask(mask)
|
||||
wxBitmapButton(self, 30, bmp, wxPoint(160, 20),
|
||||
wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
|
||||
EVT_BUTTON(self, 30, self.OnClick)
|
||||
|
||||
def OnClick(self, event):
|
||||
self.log.WriteText("Click! (%d)\n" % event.GetId())
|
||||
|
||||
def OnClick(self, event):
|
||||
self.log.write("Click! (%d)\n" % event.GetId())
|
||||
##wxLogDebug("debug message")
|
||||
|
||||
|
||||
## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@@ -43,15 +61,19 @@ def runTest(frame, nb, log):
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2>wxButton</h2>
|
||||
|
||||
A button is a control that contains a text string or a bitmap and cab be
|
||||
placed on nearly any kind of window.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -75,7 +75,7 @@ class TestPanel(wxPanel):
|
||||
|
||||
# set attributes of calendar
|
||||
|
||||
self.calend.hide_title = TRUE
|
||||
self.calend.hide_title = True
|
||||
self.calend.HideGrid()
|
||||
self.calend.SetWeekColor('WHITE', 'BLACK')
|
||||
|
||||
@@ -91,7 +91,7 @@ class TestPanel(wxPanel):
|
||||
|
||||
mID = NewId()
|
||||
self.scroll = wxScrollBar(self, mID, wxPoint(100, 240), wxSize(200, 20), wxSB_HORIZONTAL)
|
||||
self.scroll.SetScrollbar(start_month-1, 1, 12, 1, TRUE)
|
||||
self.scroll.SetScrollbar(start_month-1, 1, 12, 1, True)
|
||||
EVT_COMMAND_SCROLL(self, mID, self.Scroll)
|
||||
|
||||
# spin control for year selection
|
||||
@@ -147,8 +147,8 @@ class TestPanel(wxPanel):
|
||||
|
||||
def TestFrame(self, event):
|
||||
frame = CalendFrame(self, -1, "Test Calendar", self.log)
|
||||
frame.Show(true)
|
||||
return true
|
||||
frame.Show(True)
|
||||
return True
|
||||
|
||||
# calendar print preview
|
||||
|
||||
@@ -171,7 +171,7 @@ class TestPanel(wxPanel):
|
||||
name = event.GetString()
|
||||
self.log.WriteText('EvtComboBox: %s\n' % name)
|
||||
monthval = self.date.FindString(name)
|
||||
self.scroll.SetScrollbar(monthval, 1, 12, 1, TRUE)
|
||||
self.scroll.SetScrollbar(monthval, 1, 12, 1, True)
|
||||
|
||||
self.calend.SetMonth(monthval+1)
|
||||
self.ResetDisplay()
|
||||
@@ -366,8 +366,8 @@ class PrintCalend:
|
||||
self.sel_lst = [] # highlighted selected days
|
||||
|
||||
self.size = None
|
||||
self.hide_title = FALSE
|
||||
self.hide_grid = FALSE
|
||||
self.hide_title = False
|
||||
self.hide_grid = False
|
||||
self.set_day = None
|
||||
|
||||
def SetParms(self):
|
||||
@@ -416,7 +416,7 @@ class PrintCalend:
|
||||
frame.Initialize()
|
||||
frame.SetPosition(self.frame.GetPosition())
|
||||
frame.SetSize(self.frame.GetSize())
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
|
||||
def Print(self):
|
||||
pdd = wxPrintDialogData()
|
||||
@@ -438,7 +438,7 @@ class PrintCalend:
|
||||
|
||||
if self.preview is None:
|
||||
cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh)
|
||||
cal.SetPreview(FALSE)
|
||||
cal.SetPreview(False)
|
||||
|
||||
else:
|
||||
if self.preview == 1:
|
||||
@@ -454,7 +454,7 @@ class PrintCalend:
|
||||
cal.grid_color = self.grid_color
|
||||
cal.high_color = self.high_color
|
||||
cal.back_color = self.back_color
|
||||
cal.outer_border = FALSE
|
||||
cal.outer_border = False
|
||||
cal.font = self.font
|
||||
cal.bold = self.bold
|
||||
|
||||
@@ -534,9 +534,9 @@ class SetPrintout(wxPrintout):
|
||||
|
||||
def HasPage(self, page):
|
||||
if page <= self.end_pg:
|
||||
return true
|
||||
return True
|
||||
else:
|
||||
return false
|
||||
return False
|
||||
|
||||
def GetPageInfo(self):
|
||||
self.end_pg = self.canvas.GetTotalPages()
|
||||
@@ -594,14 +594,14 @@ class SetPrintout(wxPrintout):
|
||||
self.canvas.SetPageSize(self.psizew, self.psizeh)
|
||||
|
||||
self.canvas.DoDrawing(dc)
|
||||
return true
|
||||
return True
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = CalendFrame(None, -1, "Test Calendar")
|
||||
frame.Show(true)
|
||||
frame.Show(True)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
return True
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
@@ -19,6 +19,11 @@ class TestPanel(wxPanel):
|
||||
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
||||
self.cal = cal
|
||||
|
||||
# Set up control to display a set of holidays:
|
||||
EVT_CALENDAR_MONTH(self, cal.GetId(), self.OnChangeMonth)
|
||||
self.holidays = [(1,1), (10,31), (12,25) ] # (these don't move around)
|
||||
self.OnChangeMonth()
|
||||
|
||||
def OnButton(self, evt):
|
||||
self.cal.Destroy()
|
||||
self.cal = None
|
||||
@@ -26,6 +31,11 @@ class TestPanel(wxPanel):
|
||||
def OnCalSelected(self, evt):
|
||||
self.log.write('OnCalSelected: %s\n' % evt.GetDate())
|
||||
|
||||
def OnChangeMonth(self, evt=None):
|
||||
cur_month = self.cal.GetDate().GetMonth() + 1 # convert wxDateTime 0-11 => 1-12
|
||||
for month, day in self.holidays:
|
||||
if month == cur_month:
|
||||
self.cal.SetHoliday(day)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
@@ -14,7 +14,7 @@ class TestCheckBox(wxPanel):
|
||||
cID = NewId()
|
||||
cb1 = wxCheckBox(self, cID, " Apples", wxPoint(65, 40), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2 = wxCheckBox(self, cID+1, " Oranges", wxPoint(65, 60), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2.SetValue(true)
|
||||
cb2.SetValue(True)
|
||||
cb3 = wxCheckBox(self, cID+2, " Pears", wxPoint(65, 80), wxSize(150, 20), wxNO_BORDER)
|
||||
|
||||
EVT_CHECKBOX(self, cID, self.EvtCheckBox)
|
||||
|
@@ -22,7 +22,8 @@ class TestPanel(wxPanel):
|
||||
lb.SetSelection(0)
|
||||
self.lb = lb
|
||||
|
||||
btn = wxButton(self, -1, "Test SetString", (180, 50))
|
||||
pos = lb.GetPosition().x + lb.GetSize().width + 25
|
||||
btn = wxButton(self, -1, "Test SetString", (pos, 50))
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnTestButton)
|
||||
|
||||
EVT_RIGHT_UP(self, self.OnDoPopup)
|
||||
@@ -44,7 +45,7 @@ class TestPanel(wxPanel):
|
||||
item = wxMenuItem(menu, wxNewId(), "If supported, this is bold")
|
||||
df = wxSystemSettings_GetSystemFont(wxSYS_DEFAULT_GUI_FONT)
|
||||
nf = wxFont(df.GetPointSize(), df.GetFamily(), df.GetStyle(), wxBOLD,
|
||||
false, df.GetFaceName())
|
||||
False, df.GetFaceName())
|
||||
item.SetFont(nf)
|
||||
menu.AppendItem(item)
|
||||
|
||||
|
@@ -5,7 +5,7 @@ from wxPython.wx import *
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxColourDialog(frame)
|
||||
dlg.GetColourData().SetChooseFull(true)
|
||||
dlg.GetColourData().SetChooseFull(True)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetColourData()
|
||||
log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import string
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -35,7 +34,7 @@ class TestComboBox(wxPanel):
|
||||
cb = wxComboBox(self, 501, "default value", wxPoint(90, 80), wxSize(95, -1),
|
||||
[], wxCB_SIMPLE)
|
||||
for item in sampleList:
|
||||
cb.Append(item, string.upper(item))
|
||||
cb.Append(item, item.upper())
|
||||
EVT_COMBOBOX(self, 501, self.EvtComboBox)
|
||||
EVT_TEXT(self, 501, self.EvtText)
|
||||
|
||||
|
@@ -1,54 +1,102 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.help import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create and set a help provider. Normally you would do this in
|
||||
# the app's OnInit as it must be done before any SetHelpText calls.
|
||||
provider = wxSimpleHelpProvider()
|
||||
wxHelpProvider_Set(provider)
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestDialog(wxDialog):
|
||||
def __init__(self, parent, ID, title,
|
||||
pos=wxDefaultPosition, size=wxDefaultSize,
|
||||
style=wxDEFAULT_DIALOG_STYLE):
|
||||
|
||||
# Instead of calling wxDialog.__init__ we precreate the dialog
|
||||
# so we can set an extra style that must be set before
|
||||
# creation, and then we create the GUI dialog using the Create
|
||||
# method.
|
||||
pre = wxPreDialog()
|
||||
pre.SetExtraStyle(wxDIALOG_EX_CONTEXTHELP)
|
||||
pre.Create(parent, ID, title, pos, size, style)
|
||||
|
||||
# This next step is the most important, it turns this Python
|
||||
# object into the real wrapper of the dialog (instead of pre)
|
||||
# as far as the wxPython extension is concerned.
|
||||
self.this = pre.this
|
||||
|
||||
|
||||
# Now continue with the normal construction of the dialog
|
||||
# contents
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
label = wxStaticText(self, -1, "This is a wxDialog")
|
||||
label.SetHelpText("This is the help text for the label")
|
||||
sizer.Add(label, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
label = wxStaticText(self, -1, "Field #1:")
|
||||
label.SetHelpText("This is the help text for the label")
|
||||
box.Add(label, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
text = wxTextCtrl(self, -1, "", size=(80,-1))
|
||||
text.SetHelpText("Here's some help text for field #1")
|
||||
box.Add(text, 1, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
sizer.AddSizer(box, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5)
|
||||
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
label = wxStaticText(self, -1, "Field #2:")
|
||||
label.SetHelpText("This is the help text for the label")
|
||||
box.Add(label, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
text = wxTextCtrl(self, -1, "", size=(80,-1))
|
||||
text.SetHelpText("Here's some help text for field #2")
|
||||
box.Add(text, 1, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
sizer.AddSizer(box, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5)
|
||||
|
||||
line = wxStaticLine(self, -1, size=(20,-1), style=wxLI_HORIZONTAL)
|
||||
sizer.Add(line, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5)
|
||||
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
if wxPlatform != "__WXMSW__":
|
||||
btn = wxContextHelpButton(self)
|
||||
box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
btn = wxButton(self, wxID_OK, " OK ")
|
||||
btn.SetDefault()
|
||||
btn.SetHelpText("The OK button completes the dialog")
|
||||
box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
btn = wxButton(self, wxID_CANCEL, " Cancel ")
|
||||
btn.SetHelpText("The Cancel button cnacels the dialog. (Duh!)")
|
||||
box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
sizer.AddSizer(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(True)
|
||||
sizer.Fit(self)
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxDialog(frame, -1, "This is a wxDialog", size=wxSize(350, 200), style=wxCAPTION)
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
label = wxStaticText(win, -1, "This is a wxDialog")
|
||||
sizer.Add(label, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
label = wxStaticText(win, -1, "Field #1:")
|
||||
box.Add(label, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
text = wxTextCtrl(win, -1, "", size=(80,-1))
|
||||
box.Add(text, 1, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
sizer.AddSizer(box, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5)
|
||||
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
label = wxStaticText(win, -1, "Field #2:")
|
||||
box.Add(label, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
text = wxTextCtrl(win, -1, "", size=(80,-1))
|
||||
box.Add(text, 1, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
sizer.AddSizer(box, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5)
|
||||
|
||||
line = wxStaticLine(win, -1, size=(20,-1), style=wxLI_HORIZONTAL)
|
||||
sizer.Add(line, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5)
|
||||
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
btn = wxButton(win, wxID_OK, " OK ")
|
||||
btn.SetDefault()
|
||||
box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
btn = wxButton(win, wxID_CANCEL, " Cancel ")
|
||||
box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
|
||||
|
||||
sizer.AddSizer(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
|
||||
|
||||
win.SetSizer(sizer)
|
||||
win.SetAutoLayout(true)
|
||||
sizer.Fit(win)
|
||||
|
||||
win = TestDialog(frame, -1, "This is a wxDialog", size=wxSize(350, 200),
|
||||
#style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
|
||||
style = wxDEFAULT_DIALOG_STYLE
|
||||
)
|
||||
win.CenterOnScreen()
|
||||
val = win.ShowModal()
|
||||
if val == wxID_OK:
|
||||
log.WriteText("You pressed OK\n")
|
||||
@@ -63,10 +111,13 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -9,14 +9,14 @@ class DragShape:
|
||||
def __init__(self, bmp):
|
||||
self.bmp = bmp
|
||||
self.pos = wxPoint(0,0)
|
||||
self.shown = true
|
||||
self.shown = True
|
||||
self.text = None
|
||||
self.fullscreen = false
|
||||
self.fullscreen = False
|
||||
|
||||
|
||||
def HitTest(self, pt):
|
||||
rect = self.GetRect()
|
||||
return rect.Inside(pt.x, pt.y)
|
||||
return rect.InsideXY(pt.x, pt.y)
|
||||
|
||||
|
||||
def GetRect(self):
|
||||
@@ -31,11 +31,11 @@ class DragShape:
|
||||
|
||||
dc.Blit(self.pos.x, self.pos.y,
|
||||
self.bmp.GetWidth(), self.bmp.GetHeight(),
|
||||
memDC, 0, 0, op, true)
|
||||
memDC, 0, 0, op, True)
|
||||
|
||||
return true
|
||||
return True
|
||||
else:
|
||||
return false
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class DragCanvas(wxScrolledWindow):
|
||||
bmp = images.getTestStarBitmap()
|
||||
shape = DragShape(bmp)
|
||||
shape.pos = wxPoint(5, 5)
|
||||
shape.fullscreen = true
|
||||
shape.fullscreen = True
|
||||
self.shapes.append(shape)
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class DragCanvas(wxScrolledWindow):
|
||||
|
||||
# reposition and draw the shape
|
||||
self.dragShape.pos = self.dragShape.pos + evt.GetPosition() - self.dragStartPos
|
||||
self.dragShape.shown = true
|
||||
self.dragShape.shown = True
|
||||
self.dragShape.Draw(dc)
|
||||
self.dragShape = None
|
||||
|
||||
@@ -207,7 +207,7 @@ class DragCanvas(wxScrolledWindow):
|
||||
|
||||
# erase the shape since it will be drawn independently now
|
||||
dc = wxClientDC(self)
|
||||
self.dragShape.shown = false
|
||||
self.dragShape.shown = False
|
||||
self.EraseShape(self.dragShape, dc)
|
||||
|
||||
|
||||
@@ -228,16 +228,16 @@ class DragCanvas(wxScrolledWindow):
|
||||
# if we have shape and image then move it, posibly highlighting another shape.
|
||||
elif self.dragShape and self.dragImage:
|
||||
onShape = self.FindShape(evt.GetPosition())
|
||||
unhiliteOld = false
|
||||
hiliteNew = false
|
||||
unhiliteOld = False
|
||||
hiliteNew = False
|
||||
|
||||
# figure out what to hilite and what to unhilite
|
||||
if self.hiliteShape:
|
||||
if onShape is None or self.hiliteShape is not onShape:
|
||||
unhiliteOld = true
|
||||
unhiliteOld = True
|
||||
|
||||
if onShape and onShape is not self.hiliteShape and onShape.shown:
|
||||
hiliteNew = TRUE
|
||||
hiliteNew = True
|
||||
|
||||
# if needed, hide the drag image so we can update the window
|
||||
if unhiliteOld or hiliteNew:
|
||||
@@ -274,3 +274,10 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -89,6 +89,10 @@ class SimpleView(wxPanel):
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wxPlatform == "__WXMAC__":
|
||||
wxMessageBox("This demo currently fails on the Mac. The problem is being looked into...", "Sorry")
|
||||
return
|
||||
|
||||
if 1:
|
||||
win = wxDynamicSashWindow(nb, -1, style = 0
|
||||
| wxCLIP_CHILDREN
|
||||
@@ -149,3 +153,10 @@ You will need to set the scrollbars' event handler at three times:
|
||||
</ul>
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -10,7 +10,7 @@ def runTest(frame, nb, log):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
box.Add(ed, 1, wxALL|wxGROW, 1)
|
||||
win.SetSizer(box)
|
||||
win.SetAutoLayout(true)
|
||||
win.SetAutoLayout(True)
|
||||
|
||||
ed.SetText(["",
|
||||
"This is a simple text editor, the class name is",
|
||||
|
@@ -1,6 +1,5 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import string
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -11,8 +10,10 @@ wildcard = "Python source (*.py)|*.py|" \
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFileDialog(frame, "Choose a file", "", "", wildcard, wxOPEN|wxMULTIPLE)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
for path in dlg.GetPaths():
|
||||
log.WriteText('You selected: %s\n' % path)
|
||||
paths = dlg.GetPaths()
|
||||
log.WriteText('You selected %d files:' % len(paths))
|
||||
for path in paths:
|
||||
log.WriteText(' %s\n' % path)
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
@@ -37,7 +37,7 @@ class TestPanel(wxPanel):
|
||||
box.Add(t, 0, wxCENTER|wxALL, 5)
|
||||
|
||||
self.SetSizer(box)
|
||||
self.SetAutoLayout(true)
|
||||
self.SetAutoLayout(True)
|
||||
|
||||
# Make a menu
|
||||
self.menu = m = wxMenu()
|
||||
@@ -46,10 +46,10 @@ class TestPanel(wxPanel):
|
||||
m.Append(wxID_CLOSE, "&Close")
|
||||
m.Append(wxID_SAVE, "&Save")
|
||||
m.Append(wxID_SAVEAS, "Save &as...")
|
||||
m.Enable(wxID_NEW, false)
|
||||
m.Enable(wxID_CLOSE, false)
|
||||
m.Enable(wxID_SAVE, false)
|
||||
m.Enable(wxID_SAVEAS, false)
|
||||
m.Enable(wxID_NEW, False)
|
||||
m.Enable(wxID_CLOSE, False)
|
||||
m.Enable(wxID_SAVE, False)
|
||||
m.Enable(wxID_SAVEAS, False)
|
||||
|
||||
# and a file history
|
||||
self.filehistory = wxFileHistory()
|
||||
|
@@ -25,21 +25,21 @@ class TestPanel(wxPanel):
|
||||
data = wxFindReplaceData()
|
||||
dlg = wxFindReplaceDialog(self, data, "Find")
|
||||
dlg.data = data # save a reference to it...
|
||||
dlg.Show(true)
|
||||
dlg.Show(True)
|
||||
|
||||
|
||||
def OnShowFindReplace(self, evt):
|
||||
data = wxFindReplaceData()
|
||||
dlg = wxFindReplaceDialog(self, data, "Find & Replace", wxFR_REPLACEDIALOG)
|
||||
dlg.data = data # save a reference to it...
|
||||
dlg.Show(true)
|
||||
dlg.Show(True)
|
||||
|
||||
|
||||
def OnFind(self, evt):
|
||||
map = {
|
||||
wxEVT_COMMAND_FIND : "FIND",
|
||||
wxEVT_COMMAND_FIND_NEXT : "FIND_NEXT",
|
||||
wxEVT_COMMAND_FIND_REPLACE : "REPALCE",
|
||||
wxEVT_COMMAND_FIND_REPLACE : "REPLACE",
|
||||
wxEVT_COMMAND_FIND_REPLACE_ALL : "REPLACE_ALL",
|
||||
}
|
||||
et = evt.GetEventType()
|
||||
|