-
+
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.
+ dlg.GetColourData().SetChooseFull(True)
- # Ensure the full colour dialog is displayed,
- # not the abbreviated version.
- dlg.GetColourData().SetChooseFull(True)
+ if dlg.ShowModal() == wx.ID_OK:
- if dlg.ShowModal() == wx.ID_OK:
+ # If the user selected OK, then the dialog's wx.ColourData will
+ # contain valid information. Fetch the data ...
+ data = dlg.GetColourData()
- # If the user selected OK, then the dialog's wx.ColourData will
- # contain valid information. Fetch the data ...
- data = dlg.GetColourData()
-
- # ... 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()))
+ # ... then do something with it. The actual colour data will be
+ # returned as a three-tuple (r, g, b) in this particular case.
+ 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!
+ dlg.Destroy()
+
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return win
- # Once the dialog is destroyed, Mr. wx.ColourData is no longer your
- # friend. Don't use it again!
- dlg.Destroy()
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- win = TestDialog(frame, -1, "This is a Dialog", size=(350, 200),
- #style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
- style = wx.DEFAULT_DIALOG_STYLE
- )
- win.CenterOnScreen()
- val = win.ShowModal()
+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
+ )
+ 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")
- else:
- log.WriteText("You pressed Cancel\n")
+ if val == wx.ID_OK:
+ self.log.WriteText("You pressed OK\n")
+ else:
+ self.log.WriteText("You pressed Cancel\n")
- win.Destroy()
+ dlg.Destroy()
+
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
-
- # In this case we include a "New directory" button.
- dlg = wx.DirDialog(frame, "Choose a directory:",
- style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
+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(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:
+ self.log.WriteText('You selected: %s\n' % dlg.GetPath())
+
+ # Only destroy a dialog after you're done with it.
+ dlg.Destroy()
- # 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())
- # 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
need from the user is the name of a directory. Data is retrieved via utility
# 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|" \
+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 'open' dialog, and allows multitple
- # file selection to boot.
- #
- # Finally, of 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(),
- defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
- )
-
- # Show the dialog and retrieve the user response. If it is the OK response,
- # process the data.
- if dlg.ShowModal() == wx.ID_OK:
- # This returns a Python list of files that were selected.
- paths = dlg.GetPaths()
+#---------------------------------------------------------------------------
- log.WriteText('You selected %d files:' % len(paths))
+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 selections as well.
+ #
+ # 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(
+ self, message="Choose a file", defaultDir=os.getcwd(),
+ defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
+ )
+
+ # Show the dialog and retrieve the user response. If it is the OK response,
+ # process the data.
+ if dlg.ShowModal() == wx.ID_OK:
+ # This returns a Python list of files that were selected.
+ paths = dlg.GetPaths()
+
+ self.log.WriteText('You selected %d files:' % len(paths))
+
+ for path in paths:
+ self.log.WriteText(' %s\n' % path)
+
+ # Compare this with the debug above; did we change working dirs?
+ 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()
- for path in paths:
- log.WriteText(' %s\n' % path)
+
+
+#---------------------------------------------------------------------------
- # Compare this with the debug above; did we change working dirs?
- 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
#---------------------------------------------------------------------------
+++ /dev/null
-
-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:])
-
#---------------------------------------------------------------------------
+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(
+ self, 'FloatBar does not work well on this platform.',
+ 'Sorry', wx.OK | wx.ICON_INFORMATION
+ )
+ dlg.ShowModal()
+ dlg.Destroy()
+ else:
+ win = TestFloatBar(self, self.log)
+ win.Show(True)
+
+
+#---------------------------------------------------------------------------
+
+
def runTest(frame, nb, log):
- if wx.Platform == "__WXMAC__":
- dlg = wx.MessageDialog(
- frame, '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.Show(True)
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
StartUpDemo = "props"
import wx
import time, random
-
+
+ #---------------------------------------------------------------------------
+
+ 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))
+ win.Show(True)
+ win.DrawTest()
+
+
def runTest(frame, nb, log):
- """
- This method is used by the wxPython Demo Framework for integrating
- this demo with the rest.
- """
- win = DrawFrame(None, -1, "FloatCanvas Drawing Window",wx.DefaultPosition,(500,500))
- frame.otherWin = win
- win.Show(True)
- win.DrawTest()
+ win = TestPanel(nb, log)
+ return win
+
+
+
try:
from floatcanvas import NavCanvas, FloatCanvas
#---------------------------------------------------------------------------
+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 = MyFrame(frame, -1, "This is a wx.Frame", size=(350, 200),
- style = wx.DEFAULT_FRAME_STYLE)# | wx.FRAME_TOOL_WINDOW )
- frame.otherWin = win
- win.Show(True)
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
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
#----------------------------------------------------------------------
import images
+#---------------------------------------------------------------------------
+
class MegaTable(Grid.PyGridTableBase):
"""
A custom wx.Grid Table using user supplied data
#---------------------------------------------------------------------------
+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 = TestFrame(frame)
- frame.otherWin = win
- win.Show(True)
+ win = TestPanel(nb, log)
+ return win
import wx
import wx.lib.imagebrowser as ib
+
+
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- # get current working directory
- dir = os.getcwd()
+class TestPanel(wx.Panel):
+ def __init__(self, parent, log):
+ self.log = log
+ wx.Panel.__init__(self, parent, -1)
- # set the initial directory for the demo bitmaps
- initial_dir = os.path.join(dir, 'bitmaps')
+ b = wx.Button(self, -1, "Create and Show an ImageDialog", (50,50))
+ self.Bind(wx.EVT_BUTTON, self.OnButton, b)
- # open the image browser dialog
- win = ib.ImageDialog(frame, initial_dir)
-
- win.Centre()
- if win.ShowModal() == wx.ID_OK:
- # show the selected file
- log.WriteText("You Selected File: " + win.GetFile())
- else:
- log.WriteText("You pressed Cancel\n")
+ def OnButton(self, evt):
+ # get current working directory
+ dir = os.getcwd()
+
+ # set the initial directory for the demo bitmaps
+ initial_dir = os.path.join(dir, 'bitmaps')
+
+ # open the image browser dialog
+ dlg = ib.ImageDialog(self, initial_dir)
+
+ dlg.Centre()
+
+ if dlg.ShowModal() == wx.ID_OK:
+ # show the selected file
+ self.log.WriteText("You Selected File: " + dlg.GetFile())
+ else:
+ self.log.WriteText("You pressed Cancel\n")
+
+ dlg.Destroy()
+
+
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return win
- win.Destroy()
#---------------------------------------------------------------------------
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
- win.Show(True)
+ 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
+
#-------------------------------------------------------------------
#---------------------------------------------------------------------------
+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
+ )
+ dlg.ShowModal()
+ dlg.Destroy()
+
+
+#---------------------------------------------------------------------------
+
+
def runTest(frame, nb, log):
- dlg = wx.MessageDialog(frame, 'Hello from Python and wxPython!',
- 'A Message Box',
- wx.OK | wx.ICON_INFORMATION)
- #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION)
- dlg.ShowModal()
- dlg.Destroy()
+ win = TestPanel(nb, log)
+ return 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 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)
+ win.Show(True)
+
+
+#---------------------------------------------------------------------------
+
+
def runTest(frame, nb, log):
- win = MyMiniFrame(frame, "This is a wx.MiniFrame",
- #pos=(250,250), size=(200,200),
- style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
- win.SetSize((200, 200))
- win.CenterOnParent(wx.BOTH)
- frame.otherWin = win
- win.Show(True)
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
- 'etc', 'etc..', 'etc...' ]
+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(
+ self,
+ "Pick some from\n this list\nblah blah...",
+ "m.s.d.", lst)
- dlg = wx.lib.dialogs.MultipleChoiceDialog(
- frame,
- "Pick some from\n this list\nblah blah...",
- "m.s.d.", lst)
+ if (dlg.ShowModal() == wx.ID_OK):
+ self.log.write("Selection: %s -> %s\n" % (dlg.GetValue(), dlg.GetValueString()))
- if (dlg.ShowModal() == wx.ID_OK):
- log.write("Selection: %s -> %s\n" % (dlg.GetValue(), dlg.GetValueString()))
+ dlg.Destroy()
- dlg.Destroy()
+
+
+#---------------------------------------------------------------------------
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
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_LEFT
- #wx.NB_RIGHT
- )
+ #wx.NB_TOP # | wx.NB_MULTILINE
+ #wx.NB_BOTTOM
+ #wx.NB_LEFT
+ #wx.NB_RIGHT
+ )
self.log = log
win = self.makeColorPanel(wx.BLUE)
#---------------------------------------------------------------------------
+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(self, data)
+
+ if dlg.ShowModal() == wx.ID_OK:
+ data = dlg.GetPageSetupData()
+ tl = data.GetMarginTopLeft()
+ br = data.GetMarginBottomRight()
+ self.log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
+
+ dlg.Destroy()
+
+
+#---------------------------------------------------------------------------
+
+
def runTest(frame, nb, log):
- data = wx.PageSetupDialogData()
- data.SetMarginTopLeft( (15, 15) )
- data.SetMarginBottomRight( (15, 15) )
- #data.SetDefaultMinMargins(True)
- data.SetPaperId(wx.PAPER_LETTER)
-
- dlg = wx.PageSetupDialog(frame, 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)))
-
- dlg.Destroy()
+ win = TestPanel(nb, log)
+ return win
+
#---------------------------------------------------------------------------
import wx
+
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- data = wx.PrintDialogData()
+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)
+ data.EnablePrintToFile(True)
+ data.EnablePageNumbers(True)
+ data.SetMinPage(1)
+ data.SetMaxPage(5)
+ data.SetAllPages(True)
- data.EnableSelection(True)
- data.EnablePrintToFile(True)
- data.EnablePageNumbers(True)
- data.SetMinPage(1)
- data.SetMaxPage(5)
- data.SetAllPages(True)
+ dlg = wx.PrintDialog(self, data)
- dlg = wx.PrintDialog(frame, data)
+ if dlg.ShowModal() == wx.ID_OK:
+ data = dlg.GetPrintDialogData()
+ self.log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
- if dlg.ShowModal() == wx.ID_OK:
- data = dlg.GetPrintDialogData()
- log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
+ dlg.Destroy()
- dlg.Destroy()
+
+
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- max = 20
-
- dlg = wx.ProgressDialog("Progress dialog example",
- "An informative message",
- maximum = max,
- parent=frame,
- style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
+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=self,
+ style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
- keepGoing = True
- count = 0
+ keepGoing = True
+ count = 0
- while keepGoing and count < max:
- count = count + 1
- #print count
- wx.Sleep(1)
+ while keepGoing and count < max:
+ count = count + 1
+ #print count
+ wx.Sleep(1)
- if count == max / 2:
- keepGoing = dlg.Update(count, "Half-time!")
- else:
- keepGoing = dlg.Update(count)
+ if count == max / 2:
+ keepGoing = dlg.Update(count, "Half-time!")
+ else:
+ keepGoing = dlg.Update(count)
- dlg.Destroy()
+ dlg.Destroy()
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return 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 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(self, msg, "message test")
+ dlg.ShowModal()
+
+
+
+#---------------------------------------------------------------------------
+
+
def runTest(frame, nb, log):
- f = open("Main.py", "r")
- msg = f.read()
- f.close()
-
- dlg = wx.lib.dialogs.ScrolledMessageDialog(frame, msg, "message test")
- dlg.ShowModal()
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
self.Move(fp)
-#----------------------------------------------------------------------
+#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- win = TestFrame(nb, log)
- frame.otherWin = win
- win.Show(True)
+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
+
#----------------------------------------------------------------------
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- dlg = wx.SingleChoiceDialog(
- frame, 'Test Single Choice', 'The Caption',
- ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'],
- wx.CHOICEDLG_STYLE
- )
+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(
+ self, 'Test Single Choice', 'The Caption',
+ ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'],
+ wx.CHOICEDLG_STYLE
+ )
+
+ if dlg.ShowModal() == wx.ID_OK:
+ self.log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
- if dlg.ShowModal() == wx.ID_OK:
- log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
+ dlg.Destroy()
- dlg.Destroy()
+
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
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):
#---------------------------------------------------------------------------
+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 = TestCustomStatusBar(frame, log)
- frame.otherWin = win
- win.Show(True)
+ win = TestPanel(nb, log)
+ return win
+
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
-def runTest(frame, nb, log):
- dlg = wx.TextEntryDialog(
- frame, 'What is your favorite programming language?',
- 'Eh??', 'Python')
+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(
+ self, 'What is your favorite programming language?',
+ 'Eh??', 'Python')
+
+ dlg.SetValue("Python is the best!")
+
+ if dlg.ShowModal() == wx.ID_OK:
+ self.log.WriteText('You entered: %s\n' % dlg.GetValue())
- dlg.SetValue("Python is the best!")
-
- if dlg.ShowModal() == wx.ID_OK:
- log.WriteText('You entered: %s\n' % dlg.GetValue())
+ dlg.Destroy()
- dlg.Destroy()
+
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return 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 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
#---------------------------------------------------------------------------
+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 = TestToolBar(frame, log)
- frame.otherWin = win
- win.Show(True)
+ win = TestPanel(nb, log)
+ return win
#---------------------------------------------------------------------------
+
overview = """\
wx.ToolBar is a narrow strip of icons on one side of a frame (top, bottom, sides)
that acts much like a menu does, except it is always visible. Additionally, actual