Make all samples in the demo have a panel in the demo notebook. For

those that are frames or dialogs then the panel just has a button that
launches it.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-08-10 01:21:16 +00:00
parent ebd09fe97c
commit 34a544a635
26 changed files with 715 additions and 341 deletions

View File

@@ -3,8 +3,17 @@ import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
dlg = wx.ColourDialog(frame)
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a ColourDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
dlg = wx.ColourDialog(self)
# Ensure the full colour dialog is displayed,
# not the abbreviated version.
@@ -18,7 +27,7 @@ def runTest(frame, nb, log):
# ... then do something with it. The actual colour data will be
# returned as a three-tuple (r, g, b) in this particular case.
log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
self.log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
# Once the dialog is destroyed, Mr. wx.ColourData is no longer your
# friend. Don't use it again!
@@ -27,6 +36,14 @@ def runTest(frame, nb, log):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
This class represents the colour chooser dialog.

View File

@@ -86,22 +86,40 @@ class TestDialog(wx.Dialog):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestDialog(frame, -1, "This is a Dialog", size=(350, 200),
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a custom Dialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
dlg = TestDialog(self, -1, "This is a Dialog", size=(350, 200),
#style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
style = wx.DEFAULT_DIALOG_STYLE
)
win.CenterOnScreen()
val = win.ShowModal()
dlg.CenterOnScreen()
# this does not return until the dialog is closed.
val = dlg.ShowModal()
if val == wx.ID_OK:
log.WriteText("You pressed OK\n")
self.log.WriteText("You pressed OK\n")
else:
log.WriteText("You pressed Cancel\n")
self.log.WriteText("You pressed Cancel\n")
win.Destroy()
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -3,24 +3,42 @@ import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a DirDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
# In this case we include a "New directory" button.
dlg = wx.DirDialog(frame, "Choose a directory:",
dlg = wx.DirDialog(self, "Choose a directory:",
style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
# If the user selects OK, then we process the dialog's data.
# This is done by getting the path data from the dialog - BEFORE
# we destroy it.
if dlg.ShowModal() == wx.ID_OK:
log.WriteText('You selected: %s\n' % dlg.GetPath())
self.log.WriteText('You selected: %s\n' % dlg.GetPath())
# Only destroy a dialog after you're done with it.
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
This class represents the directory chooser dialog. It is used when all you

View File

@@ -8,20 +8,36 @@ import wx
# only shows the extension(s) you want it to.
wildcard = "Python source (*.py)|*.py|" \
"Compiled Python (*.pyc)|*.pyc|" \
"SPAM files (*.spam)|*.spam|" \
"Egg file (*.egg)|*.egg|" \
"All files (*.*)|*.*"
def runTest(frame, nb, log):
log.WriteText("CWD: %s\n" % os.getcwd())
#---------------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show an OPEN FileDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
b = wx.Button(self, -1, "Create and Show a SAVE FileDialog", (50,90))
self.Bind(wx.EVT_BUTTON, self.OnButton2, b)
def OnButton(self, evt):
self.log.WriteText("CWD: %s\n" % os.getcwd())
# Create the dialog. In this case the current directory is forced as the starting
# directory for the dialog, and no default file name is forced. This can easilly
# be changed in your program. This is an 'open' dialog, and allows multitple
# file selection to boot.
# file selections as well.
#
# Finally, of the directory is changed in the process of getting files, this
# Finally, if the directory is changed in the process of getting files, this
# dialog is set up to change the current working directory to the path chosen.
dlg = wx.FileDialog(
frame, message="Choose a file", defaultDir=os.getcwd(),
self, message="Choose a file", defaultDir=os.getcwd(),
defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
)
@@ -31,18 +47,76 @@ def runTest(frame, nb, log):
# This returns a Python list of files that were selected.
paths = dlg.GetPaths()
log.WriteText('You selected %d files:' % len(paths))
self.log.WriteText('You selected %d files:' % len(paths))
for path in paths:
log.WriteText(' %s\n' % path)
self.log.WriteText(' %s\n' % path)
# Compare this with the debug above; did we change working dirs?
log.WriteText("CWD: %s\n" % os.getcwd())
self.log.WriteText("CWD: %s\n" % os.getcwd())
# Destroy the dialog. Don't do this until you are done with it!
# BAD things can happen otherwise!
dlg.Destroy()
def OnButton2(self, evt):
self.log.WriteText("CWD: %s\n" % os.getcwd())
# Create the dialog. In this case the current directory is forced as the starting
# directory for the dialog, and no default file name is forced. This can easilly
# be changed in your program. This is an 'save' dialog.
#
# Unlike the 'open dialog' example found elsewhere, this example does NOT
# force the current working directory to change if the user chooses a different
# directory than the one initially set.
dlg = wx.FileDialog(
self, message="Save file as ...", defaultDir=os.getcwd(),
defaultFile="", wildcard=wildcard, style=wx.SAVE
)
# This sets the default filter that the user will initially see. Otherwise,
# the first filter in the list will be used by default.
dlg.SetFilterIndex(2)
# Show the dialog and retrieve the user response. If it is the OK response,
# process the data.
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
self.log.WriteText('You selected "%s"' % path)
# Normally, at this point you would save your data using the file and path
# data that the user provided to you, but since we didn't actually start
# with any data to work with, that would be difficult.
#
# The code to do so would be similar to this, assuming 'data' contains
# the data you want to save:
#
# fp = file(path, 'w') # Create file anew
# fp.write(data)
# fp.close()
#
# You might want to add some error checking :-)
#
# Note that the current working dir didn't change. This is good since
# that's the way we set it up.
self.log.WriteText("CWD: %s\n" % os.getcwd())
# Destroy the dialog. Don't do this until you are done with it!
# BAD things can happen otherwise!
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -1,87 +0,0 @@
import os
import wx
#---------------------------------------------------------------------------
# This is how you pre-establish a file filter so that the dialog
# only shows the extension(s) you want it to.
wildcard = "Python source (*.py)|*.py|" \
"Compiled Python (*.pyc)|*.pyc|" \
"SPAM files (*.spam)|*.spam|" \
"Egg file (*.egg)|*.egg|" \
"All files (*.*)|*.*"
def runTest(frame, nb, log):
log.WriteText("CWD: %s\n" % os.getcwd())
# Create the dialog. In this case the current directory is forced as the starting
# directory for the dialog, and no default file name is forced. This can easilly
# be changed in your program. This is an 'save' dialog.
#
# Unlike the 'open dialog' example found elsewhere, this example does NOT
# force the current working directory to change if the user chooses a different
# directory than the one initially set.
dlg = wx.FileDialog(
frame, message="Save file as ...", defaultDir=os.getcwd(),
defaultFile="", wildcard=wildcard, style=wx.SAVE
)
# This sets the default filter that the user will initially see. Otherwise,
# the first filter in the list will be used by default.
dlg.SetFilterIndex(2)
# Show the dialog and retrieve the user response. If it is the OK response,
# process the data.
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
log.WriteText('You selected "%s"' % path)
# Normally, at this point you would save your data using the file and path
# data that the user provided to you, but since we didn't actually start
# with any data to work with, that would be difficult.
#
# The code to do so would be similar to this, assuming 'data' contains
# the data you want to save:
#
# fp = file(path, 'w') # Create file anew
# fp.write(data)
# fp.close()
#
# You might want to add some error checking :-)
#
# Note that the current working dir didn't change. This is good since
# that's the way we set it up.
log.WriteText("CWD: %s\n" % os.getcwd())
# Destroy the dialog. Don't do this until you are done with it!
# BAD things can happen otherwise!
dlg.Destroy()
#---------------------------------------------------------------------------
overview = """\
This class provides the file selection dialog. It incorporates OS-native features
depending on the OS in use, and can be used both for open and save operations.
The files displayed can be filtered by setting up a wildcard filter, multiple files
can be selected (open only), and files can be forced in a read-only mode.
There are two ways to get the results back from the dialog. GetFiles() returns only
the file names themselves, in a Python list. GetPaths() returns the full path and
filenames combined as a Python list.
One important thing to note: if you use the file extension filters, then files saved
with the filter set to something will automatically get that extension appended to them
if it is not already there. For example, suppose the dialog was displaying the 'egg'
extension and you entered a file name of 'fried'. It would be saved as 'fried.egg.'
Yum!
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

View File

@@ -80,19 +80,35 @@ class TestFloatBar(wx.Frame):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show the FloatBar sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
if wx.Platform == "__WXMAC__":
dlg = wx.MessageDialog(
frame, 'FloatBar does not work well on this platform.',
self, 'FloatBar does not work well on this platform.',
'Sorry', wx.OK | wx.ICON_INFORMATION
)
dlg.ShowModal()
dlg.Destroy()
else:
win = TestFloatBar(frame, log)
frame.otherWin = win
win = TestFloatBar(self, self.log)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\

View File

@@ -60,16 +60,30 @@ else:
import wx
import time, random
def runTest(frame, nb, log):
"""
This method is used by the wxPython Demo Framework for integrating
this demo with the rest.
"""
#---------------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show the FloatBar sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = DrawFrame(None, -1, "FloatCanvas Drawing Window",wx.DefaultPosition,(500,500))
frame.otherWin = win
win.Show(True)
win.DrawTest()
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
try:
from floatcanvas import NavCanvas, FloatCanvas
except ImportError: # if it's not there locally, try the wxPython lib.

View File

@@ -26,13 +26,30 @@ class MyFrame(wx.Frame):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = MyFrame(frame, -1, "This is a wx.Frame", size=(350, 200),
style = wx.DEFAULT_FRAME_STYLE)# | wx.FRAME_TOOL_WINDOW )
frame.otherWin = win
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a Frame", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = MyFrame(self, -1, "This is a wx.Frame", size=(350, 200),
style = wx.DEFAULT_FRAME_STYLE)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -117,12 +117,29 @@ assert when compiled in debug mode.""",
print "item found: ", `item.GetPos()`, "--", `item.GetSpan()`
#----------------------------------------------------------------------
#---------------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show the GridBagSizer sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = TestFrame()
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestFrame()
frame.otherWin = win
win.Show(True)
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------

View File

@@ -4,6 +4,8 @@ import wx.grid as Grid
import images
#---------------------------------------------------------------------------
class MegaTable(Grid.PyGridTableBase):
"""
A custom wx.Grid Table using user supplied data
@@ -444,11 +446,26 @@ class TestFrame(wx.Frame):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestFrame(frame)
frame.otherWin = win
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show the MegaGrid", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = TestFrame(self)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
overview = """Mega Grid Example

View File

@@ -13,9 +13,20 @@ import os
import wx
import wx.lib.imagebrowser as ib
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show an ImageDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
# get current working directory
dir = os.getcwd()
@@ -23,17 +34,26 @@ def runTest(frame, nb, log):
initial_dir = os.path.join(dir, 'bitmaps')
# open the image browser dialog
win = ib.ImageDialog(frame, initial_dir)
dlg = ib.ImageDialog(self, initial_dir)
win.Centre()
dlg.Centre()
if win.ShowModal() == wx.ID_OK:
if dlg.ShowModal() == wx.ID_OK:
# show the selected file
log.WriteText("You Selected File: " + win.GetFile())
self.log.WriteText("You Selected File: " + dlg.GetFile())
else:
log.WriteText("You pressed Cancel\n")
self.log.WriteText("You pressed Cancel\n")
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
win.Destroy()
#---------------------------------------------------------------------------

View File

@@ -251,16 +251,29 @@ check the source for this sample to see how to implement them.
menu.InsertItem(pos, item)
#-------------------------------------------------------------------
#---------------------------------------------------------------------------
wx.RegisterId(10000)
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
def runTest(frame, nb, log):
win = MyFrame(frame, -1, log)
frame.otherWin = win
b = wx.Button(self, -1, "Show the Menu sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = MyFrame(self, -1, self.log)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#-------------------------------------------------------------------

View File

@@ -3,14 +3,33 @@ import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
dlg = wx.MessageDialog(frame, 'Hello from Python and wxPython!',
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a MessageDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
dlg = wx.MessageDialog(self, 'Hello from Python and wxPython!',
'A Message Box',
wx.OK | wx.ICON_INFORMATION)
#wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION)
wx.OK | wx.ICON_INFORMATION
#wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
)
dlg.ShowModal()
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -25,19 +25,34 @@ class MyMiniFrame(wx.MiniFrame):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = MyMiniFrame(frame, "This is a wx.MiniFrame",
#pos=(250,250), size=(200,200),
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a MiniFrame", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = MyMiniFrame(self, "This is a wx.MiniFrame",
style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
win.SetSize((200, 200))
win.CenterOnParent(wx.BOTH)
frame.otherWin = win
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
A MiniFrame is a Frame with a small title bar. It is suitable for floating
toolbars that must not take up too much screen area. In other respects, it's the

View File

@@ -4,20 +4,38 @@ import wx.lib.dialogs
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a MultipleChoiceDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange', 'grape', 'pineapple',
'blueberry', 'raspberry', 'blackberry', 'snozzleberry',
'etc', 'etc..', 'etc...' ]
dlg = wx.lib.dialogs.MultipleChoiceDialog(
frame,
self,
"Pick some from\n this list\nblah blah...",
"m.s.d.", lst)
if (dlg.ShowModal() == wx.ID_OK):
log.write("Selection: %s -> %s\n" % (dlg.GetValue(), dlg.GetValueString()))
self.log.write("Selection: %s -> %s\n" % (dlg.GetValue(), dlg.GetValueString()))
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -15,7 +15,7 @@ class TestNB(wx.Notebook):
def __init__(self, parent, id, log):
wx.Notebook.__init__(self, parent, id, size=(21,21), style=
#wx.NB_TOP # | wx.NB_MULTILINE
wx.NB_BOTTOM
#wx.NB_BOTTOM
#wx.NB_LEFT
#wx.NB_RIGHT
)

View File

@@ -3,23 +3,41 @@ import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a PageSetupDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
data = wx.PageSetupDialogData()
data.SetMarginTopLeft( (15, 15) )
data.SetMarginBottomRight( (15, 15) )
#data.SetDefaultMinMargins(True)
data.SetPaperId(wx.PAPER_LETTER)
dlg = wx.PageSetupDialog(frame, data)
dlg = wx.PageSetupDialog(self, data)
if dlg.ShowModal() == wx.ID_OK:
data = dlg.GetPageSetupData()
tl = data.GetMarginTopLeft()
br = data.GetMarginBottomRight()
log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
self.log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -1,8 +1,18 @@
import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a PrintDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
data = wx.PrintDialogData()
data.EnableSelection(True)
@@ -12,14 +22,23 @@ def runTest(frame, nb, log):
data.SetMaxPage(5)
data.SetAllPages(True)
dlg = wx.PrintDialog(frame, data)
dlg = wx.PrintDialog(self, data)
if dlg.ShowModal() == wx.ID_OK:
data = dlg.GetPrintDialogData()
log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
self.log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -12,13 +12,22 @@ import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a ProgressDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
max = 20
dlg = wx.ProgressDialog("Progress dialog example",
"An informative message",
maximum = max,
parent=frame,
parent=self,
style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
keepGoing = True
@@ -36,6 +45,12 @@ def runTest(frame, nb, log):
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -4,14 +4,32 @@ import wx.lib.dialogs
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a ScrolledMessageDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
f = open("Main.py", "r")
msg = f.read()
f.close()
dlg = wx.lib.dialogs.ScrolledMessageDialog(frame, msg, "message test")
dlg = wx.lib.dialogs.ScrolledMessageDialog(self, msg, "message test")
dlg.ShowModal()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -90,13 +90,27 @@ class TestFrame(wx.Frame):
self.Move(fp)
#----------------------------------------------------------------------
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestFrame(nb, log)
frame.otherWin = win
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show the ShapedWindow sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = TestFrame(self, self.log)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------

View File

@@ -3,18 +3,35 @@ import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a SingleChoiceDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
dlg = wx.SingleChoiceDialog(
frame, 'Test Single Choice', 'The Caption',
self, 'Test Single Choice', 'The Caption',
['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'],
wx.CHOICEDLG_STYLE
)
if dlg.ShowModal() == wx.ID_OK:
log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
self.log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -84,7 +84,7 @@ class TestCustomStatusBar(wx.Frame):
self.SetStatusBar(self.sb)
tc = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE)
self.SetSize((500, 300))
self.SetSize((640, 480))
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def OnCloseWindow(self, event):
@@ -94,14 +94,30 @@ class TestCustomStatusBar(wx.Frame):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestCustomStatusBar(frame, log)
frame.otherWin = win
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show the StatusBar sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = TestCustomStatusBar(self, self.log)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
A status bar is a narrow window that can be placed along the bottom of
a frame to give small amounts of status information. It can contain

View File

@@ -3,19 +3,37 @@ import wx
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a TextEntryDialog", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
dlg = wx.TextEntryDialog(
frame, 'What is your favorite programming language?',
self, 'What is your favorite programming language?',
'Eh??', 'Python')
dlg.SetValue("Python is the best!")
if dlg.ShowModal() == wx.ID_OK:
log.WriteText('You entered: %s\n' % dlg.GetValue())
self.log.WriteText('You entered: %s\n' % dlg.GetValue())
dlg.Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------

View File

@@ -212,19 +212,35 @@ class TestFrame(wx.Frame):
#----------------------------------------------------------------------
#---------------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show Threads sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = TestFrame(frame, log)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestFrame(frame, log)
frame.otherWin = win
win.Show(True)
return None
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------
overview = """\
The main issue with multi-threaded GUI programming is the thread safty
of the GUI itself. On most platforms the GUI is not thread safe and

View File

@@ -118,14 +118,31 @@ class TestToolBar(wx.Frame):
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestToolBar(frame, log)
frame.otherWin = win
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Show the ToolBar sample", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = TestToolBar(self, self.log)
win.Show(True)
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
wx.ToolBar is a narrow strip of icons on one side of a frame (top, bottom, sides)