]> git.saurik.com Git - wxWidgets.git/commitdiff
Make all samples in the demo have a panel in the demo notebook. For
authorRobin Dunn <robin@alldunn.com>
Tue, 10 Aug 2004 01:21:16 +0000 (01:21 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 10 Aug 2004 01:21:16 +0000 (01:21 +0000)
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

26 files changed:
wxPython/demo/ColourDialog.py
wxPython/demo/Dialog.py
wxPython/demo/DirDialog.py
wxPython/demo/FileDialog.py
wxPython/demo/FileDialog_Save.py [deleted file]
wxPython/demo/FloatBar.py
wxPython/demo/FloatCanvas.py
wxPython/demo/Frame.py
wxPython/demo/GridBagSizer.py
wxPython/demo/Grid_MegaExample.py
wxPython/demo/ImageBrowser.py
wxPython/demo/Menu.py
wxPython/demo/MessageDialog.py
wxPython/demo/MiniFrame.py
wxPython/demo/MultipleChoiceDialog.py
wxPython/demo/Notebook.py
wxPython/demo/PageSetupDialog.py
wxPython/demo/PrintDialog.py
wxPython/demo/ProgressDialog.py
wxPython/demo/ScrolledMessageDialog.py
wxPython/demo/ShapedWindow.py
wxPython/demo/SingleChoiceDialog.py
wxPython/demo/StatusBar.py
wxPython/demo/TextEntryDialog.py
wxPython/demo/Threads.py
wxPython/demo/ToolBar.py

index 79657a04c88f13fdd8323d91c4be912e40b846d9..13422421dd6a40cc976df346daf65fdff7f46fd7 100644 (file)
@@ -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()
 
 #---------------------------------------------------------------------------
 
index 0b6e4243ce233f59784b489174fbe25e169d7a9a..e9dc898a7608f553c856985d8d1754e2e49cfcaa 100644 (file)
@@ -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
 
 
 #---------------------------------------------------------------------------
index c8ad180c24bc5bef810c58f3280da16979795733..c1b1c2a4331e1e2d78ded91e3f4cdb5b1176e166 100644 (file)
@@ -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
index 903f14dbfb494711f58b49da0bd0efd7324b03e6..4c3a6646761b1576208040d74fd33e2b3c1271c5 100644 (file)
@@ -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 (file)
index 1edda13..0000000
+++ /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:])
-
index 8be8583649be3bfcee35ce25bf901281c7f19d5c..1b7d7c91932118268850f55e361fd88dbd036f2f 100644 (file)
@@ -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
 
 #---------------------------------------------------------------------------
 
index 0c1f670d1fc881eb0502b56e2e2443032670736a..aeec720a8bcf94ad821cec92ad938d32dd3c09ea 100644 (file)
@@ -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
index f58a3c0e140e17d91d5e9b88518f64b3c26bdd96..6a20509499d2f398813f912c08b2a4dcdcbdde98 100644 (file)
@@ -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
 
 
 #---------------------------------------------------------------------------
index 8bf5807446dfb85f666d133a1f53e67df0edce82..c6a223782c98def1fd2eb90f20124d425a71f2c0 100644 (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
 
 
 #----------------------------------------------------------------------
index 4eafd68ab2c04122aff72a91618452cc2fec156b..acb41434f18e80b6201db699338e678be07bf0cb 100644 (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,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
 
 
 
index 863416584ef63af03b400453105a0b438a179377..31509a9d0eaeb429bcda47a1cd3d602916fd469d 100644 (file)
@@ -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()
     
 #---------------------------------------------------------------------------
 
index 431ab66812115914a1a484c11f0b56cf684d22fe..57bd44ce8077d91c37f1d6b147e7a77d81d2eaad 100644 (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
-    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
+
 #-------------------------------------------------------------------
 
 
index 7b9cdc7b2717157ae2f917876b2e77f25ca5db02..75dd639fa4429a37fa2abac37f0f00f3d0445fdd 100644 (file)
@@ -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
+
 
 #---------------------------------------------------------------------------
 
index 7bdc8b1de888eab83499ce363985b7b8d6966ba9..2bea751fdd86835e8c287a9a27ae686b30804733 100644 (file)
@@ -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
 
 
 #---------------------------------------------------------------------------
index df85431ffa7386be5a3a5b8d06d8887650b9e789..3a36e9872f7d95b040ed11a15a33c499015495ac 100644 (file)
@@ -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
 
 #---------------------------------------------------------------------------
 
index b9305add34edfcda97355ff8c08b7b0d2f0ebdf9..9637ba95fae62dc07ce9a01370d0c0de60e4f757 100644 (file)
@@ -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)
index bae4d0d81e8968204a0a0a9ebcea7d438fedbf23..d81a314908234efa69a0cb1100361db355344f39 100644 (file)
@@ -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
+
 
 #---------------------------------------------------------------------------
 
index 4e602f2bda2fb72fc68c9db6ee22dfcb2f56dacc..e86dddf2f1465293b95b79041a6bd050006ddb90 100644 (file)
@@ -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
 
 #---------------------------------------------------------------------------
 
index 6a5fe70cfe6a70c95713f7211ce8567e9001d42f..ae81a04fde8eb6a1e76d08ca17cbd856cd89c09b 100644 (file)
@@ -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
 
 #---------------------------------------------------------------------------
 
index 65647f8caed4ed0e20db2c393e7f5e1b09304c50..8620a7b174c29d21d69e70ed015e185e3643662c 100644 (file)
@@ -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
 
 #---------------------------------------------------------------------------
 
index 277f07619d8849d7da7512f55c133d1bb5b425c1..26361a7d12b80e0de3d62c5adba0cfd9c48c3ed4 100644 (file)
@@ -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
+
 #----------------------------------------------------------------------
 
 
index 0f20cdcf14890ed8d74824a15b5c7dde52a3992c..2317d7e398306a33caedee12b153fea70ab754f7 100644 (file)
@@ -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
 #---------------------------------------------------------------------------
 
 
index 6cfa844648d562d3f9f3895fa9194764a5580dad..a718a5683b5e1ae409b94bb6603ea037013a295e 100644 (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,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
+
 
 #---------------------------------------------------------------------------
 
index 6f48afbacd73513a3f4718a4151a524578f9d29a..568095aac3a9979619fedb303ee17c265c5316aa 100644 (file)
@@ -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
+
 #---------------------------------------------------------------------------
 
 
index b4ef61f9fcd948b8c0856fe9597b19925722a647..8e64bf83476ad597c37f96be0216c0920d013b83 100644 (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
index 4c0414128fcf223625fc54b75193e695fc7a5d4d..6589abf20f953c359df4916956ced439cb41d4ea 100644 (file)
@@ -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