From 34a544a635f3bac9320e6eb41aaaa5a5e8d1f5a4 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 10 Aug 2004 01:21:16 +0000 Subject: [PATCH 1/1] 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 --- wxPython/demo/ColourDialog.py | 51 ++++++---- wxPython/demo/Dialog.py | 42 +++++--- wxPython/demo/DirDialog.py | 42 +++++--- wxPython/demo/FileDialog.py | 132 +++++++++++++++++++------ wxPython/demo/FileDialog_Save.py | 87 ---------------- wxPython/demo/FloatBar.py | 38 ++++--- wxPython/demo/FloatCanvas.py | 32 ++++-- wxPython/demo/Frame.py | 25 ++++- wxPython/demo/GridBagSizer.py | 25 ++++- wxPython/demo/Grid_MegaExample.py | 23 ++++- wxPython/demo/ImageBrowser.py | 50 +++++++--- wxPython/demo/Menu.py | 25 +++-- wxPython/demo/MessageDialog.py | 31 ++++-- wxPython/demo/MiniFrame.py | 29 ++++-- wxPython/demo/MultipleChoiceDialog.py | 38 +++++-- wxPython/demo/Notebook.py | 10 +- wxPython/demo/PageSetupDialog.py | 48 ++++++--- wxPython/demo/PrintDialog.py | 45 ++++++--- wxPython/demo/ProgressDialog.py | 53 ++++++---- wxPython/demo/ScrolledMessageDialog.py | 30 ++++-- wxPython/demo/ShapedWindow.py | 24 ++++- wxPython/demo/SingleChoiceDialog.py | 35 +++++-- wxPython/demo/StatusBar.py | 24 ++++- wxPython/demo/TextEntryDialog.py | 36 +++++-- wxPython/demo/Threads.py | 26 ++++- wxPython/demo/ToolBar.py | 23 ++++- 26 files changed, 699 insertions(+), 325 deletions(-) delete mode 100644 wxPython/demo/FileDialog_Save.py diff --git a/wxPython/demo/ColourDialog.py b/wxPython/demo/ColourDialog.py index 79657a04c8..13422421dd 100644 --- a/wxPython/demo/ColourDialog.py +++ b/wxPython/demo/ColourDialog.py @@ -1,28 +1,45 @@ - + 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() #--------------------------------------------------------------------------- diff --git a/wxPython/demo/Dialog.py b/wxPython/demo/Dialog.py index 0b6e4243ce..e9dc898a76 100644 --- a/wxPython/demo/Dialog.py +++ b/wxPython/demo/Dialog.py @@ -86,21 +86,39 @@ class TestDialog(wx.Dialog): #--------------------------------------------------------------------------- -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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/DirDialog.py b/wxPython/demo/DirDialog.py index c8ad180c24..c1b1c2a433 100644 --- a/wxPython/demo/DirDialog.py +++ b/wxPython/demo/DirDialog.py @@ -3,25 +3,43 @@ import wx #--------------------------------------------------------------------------- -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 diff --git a/wxPython/demo/FileDialog.py b/wxPython/demo/FileDialog.py index 903f14dbfb..4c3a664676 100644 --- a/wxPython/demo/FileDialog.py +++ b/wxPython/demo/FileDialog.py @@ -6,42 +6,116 @@ 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|" \ +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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/FileDialog_Save.py b/wxPython/demo/FileDialog_Save.py deleted file mode 100644 index 1edda13224..0000000000 --- a/wxPython/demo/FileDialog_Save.py +++ /dev/null @@ -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:]) - diff --git a/wxPython/demo/FloatBar.py b/wxPython/demo/FloatBar.py index 8be8583649..1b7d7c9193 100644 --- a/wxPython/demo/FloatBar.py +++ b/wxPython/demo/FloatBar.py @@ -80,18 +80,34 @@ class TestFloatBar(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 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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/FloatCanvas.py b/wxPython/demo/FloatCanvas.py index 0c1f670d1f..aeec720a8b 100644 --- a/wxPython/demo/FloatCanvas.py +++ b/wxPython/demo/FloatCanvas.py @@ -59,16 +59,30 @@ else: 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 diff --git a/wxPython/demo/Frame.py b/wxPython/demo/Frame.py index f58a3c0e14..6a20509499 100644 --- a/wxPython/demo/Frame.py +++ b/wxPython/demo/Frame.py @@ -26,11 +26,28 @@ class MyFrame(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, "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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/GridBagSizer.py b/wxPython/demo/GridBagSizer.py index 8bf5807446..c6a223782c 100644 --- a/wxPython/demo/GridBagSizer.py +++ b/wxPython/demo/GridBagSizer.py @@ -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 #---------------------------------------------------------------------- diff --git a/wxPython/demo/Grid_MegaExample.py b/wxPython/demo/Grid_MegaExample.py index 4eafd68ab2..acb41434f1 100644 --- a/wxPython/demo/Grid_MegaExample.py +++ b/wxPython/demo/Grid_MegaExample.py @@ -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,10 +446,25 @@ 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 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 diff --git a/wxPython/demo/ImageBrowser.py b/wxPython/demo/ImageBrowser.py index 863416584e..31509a9d0e 100644 --- a/wxPython/demo/ImageBrowser.py +++ b/wxPython/demo/ImageBrowser.py @@ -13,27 +13,47 @@ import os 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() #--------------------------------------------------------------------------- diff --git a/wxPython/demo/Menu.py b/wxPython/demo/Menu.py index 431ab66812..57bd44ce80 100644 --- a/wxPython/demo/Menu.py +++ b/wxPython/demo/Menu.py @@ -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 - 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 + #------------------------------------------------------------------- diff --git a/wxPython/demo/MessageDialog.py b/wxPython/demo/MessageDialog.py index 7b9cdc7b27..75dd639fa4 100644 --- a/wxPython/demo/MessageDialog.py +++ b/wxPython/demo/MessageDialog.py @@ -3,13 +3,32 @@ import wx #--------------------------------------------------------------------------- +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 + #--------------------------------------------------------------------------- diff --git a/wxPython/demo/MiniFrame.py b/wxPython/demo/MiniFrame.py index 7bdc8b1de8..2bea751fdd 100644 --- a/wxPython/demo/MiniFrame.py +++ b/wxPython/demo/MiniFrame.py @@ -25,14 +25,29 @@ class MyMiniFrame(wx.MiniFrame): #--------------------------------------------------------------------------- +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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/MultipleChoiceDialog.py b/wxPython/demo/MultipleChoiceDialog.py index df85431ffa..3a36e9872f 100644 --- a/wxPython/demo/MultipleChoiceDialog.py +++ b/wxPython/demo/MultipleChoiceDialog.py @@ -4,19 +4,37 @@ import wx.lib.dialogs #--------------------------------------------------------------------------- -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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/Notebook.py b/wxPython/demo/Notebook.py index b9305add34..9637ba95fa 100644 --- a/wxPython/demo/Notebook.py +++ b/wxPython/demo/Notebook.py @@ -14,11 +14,11 @@ import images 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) diff --git a/wxPython/demo/PageSetupDialog.py b/wxPython/demo/PageSetupDialog.py index bae4d0d81e..d81a314908 100644 --- a/wxPython/demo/PageSetupDialog.py +++ b/wxPython/demo/PageSetupDialog.py @@ -3,22 +3,40 @@ import wx #--------------------------------------------------------------------------- +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 + #--------------------------------------------------------------------------- diff --git a/wxPython/demo/PrintDialog.py b/wxPython/demo/PrintDialog.py index 4e602f2bda..e86dddf2f1 100644 --- a/wxPython/demo/PrintDialog.py +++ b/wxPython/demo/PrintDialog.py @@ -1,24 +1,43 @@ 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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/ProgressDialog.py b/wxPython/demo/ProgressDialog.py index 6a5fe70cfe..ae81a04fde 100644 --- a/wxPython/demo/ProgressDialog.py +++ b/wxPython/demo/ProgressDialog.py @@ -12,30 +12,45 @@ import wx #--------------------------------------------------------------------------- -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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/ScrolledMessageDialog.py b/wxPython/demo/ScrolledMessageDialog.py index 65647f8cae..8620a7b174 100644 --- a/wxPython/demo/ScrolledMessageDialog.py +++ b/wxPython/demo/ScrolledMessageDialog.py @@ -4,13 +4,31 @@ import wx.lib.dialogs #--------------------------------------------------------------------------- +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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/ShapedWindow.py b/wxPython/demo/ShapedWindow.py index 277f07619d..26361a7d12 100644 --- a/wxPython/demo/ShapedWindow.py +++ b/wxPython/demo/ShapedWindow.py @@ -90,14 +90,28 @@ class TestFrame(wx.Frame): 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 + #---------------------------------------------------------------------- diff --git a/wxPython/demo/SingleChoiceDialog.py b/wxPython/demo/SingleChoiceDialog.py index 0f20cdcf14..2317d7e398 100644 --- a/wxPython/demo/SingleChoiceDialog.py +++ b/wxPython/demo/SingleChoiceDialog.py @@ -3,18 +3,35 @@ import wx #--------------------------------------------------------------------------- -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 #--------------------------------------------------------------------------- diff --git a/wxPython/demo/StatusBar.py b/wxPython/demo/StatusBar.py index 6cfa844648..a718a5683b 100644 --- a/wxPython/demo/StatusBar.py +++ b/wxPython/demo/StatusBar.py @@ -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,10 +94,26 @@ class TestCustomStatusBar(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 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 + #--------------------------------------------------------------------------- diff --git a/wxPython/demo/TextEntryDialog.py b/wxPython/demo/TextEntryDialog.py index 6f48afbacd..568095aac3 100644 --- a/wxPython/demo/TextEntryDialog.py +++ b/wxPython/demo/TextEntryDialog.py @@ -3,19 +3,37 @@ import wx #--------------------------------------------------------------------------- -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 + #--------------------------------------------------------------------------- diff --git a/wxPython/demo/Threads.py b/wxPython/demo/Threads.py index b4ef61f9fc..8e64bf8347 100644 --- a/wxPython/demo/Threads.py +++ b/wxPython/demo/Threads.py @@ -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 diff --git a/wxPython/demo/ToolBar.py b/wxPython/demo/ToolBar.py index 4c0414128f..6589abf20f 100644 --- a/wxPython/demo/ToolBar.py +++ b/wxPython/demo/ToolBar.py @@ -118,15 +118,32 @@ class TestToolBar(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 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 -- 2.45.2