]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/Main.py
Fix "warning: operation on 'y' may be undefined".
[wxWidgets.git] / wxPython / demo / Main.py
index 458c1a713acb804719e703a2be2e3aa6989d6894..152a858a44646e4edd3231332691fc6c0aeb285a 100644 (file)
@@ -47,7 +47,10 @@ import images
 _treeList = [
     # new stuff
     ('Recent Additions/Updates', [
 _treeList = [
     # new stuff
     ('Recent Additions/Updates', [
-        'StandardPaths',
+        'FoldPanelBar',
+        'GIFAnimationCtrl',
+        'HyperLinkCtrl',
+        'MultiSplitterWindow',
         ]),
 
     # managed windows == things with a (optional) caption you can close
         ]),
 
     # managed windows == things with a (optional) caption you can close
@@ -67,6 +70,7 @@ _treeList = [
         'FindReplaceDialog',
         'FontDialog',
         'MessageDialog',
         'FindReplaceDialog',
         'FontDialog',
         'MessageDialog',
+        'MultiChoiceDialog',
         'PageSetupDialog',
         'PrintDialog',
         'ProgressDialog',
         'PageSetupDialog',
         'PrintDialog',
         'ProgressDialog',
@@ -111,6 +115,7 @@ _treeList = [
         'SpinCtrl',
         'SplitterWindow',
         'StaticBitmap',
         'SpinCtrl',
         'SplitterWindow',
         'StaticBitmap',
+        'StaticBox',
         'StaticText',
         'StatusBar',
         'StockButtons',
         'StaticText',
         'StatusBar',
         'StockButtons',
@@ -143,14 +148,20 @@ _treeList = [
         'Calendar',
         'CalendarCtrl',
         'ContextHelp',
         'Calendar',
         'CalendarCtrl',
         'ContextHelp',
+        'DatePickerCtrl',
         'DynamicSashWindow',
         'EditableListBox',
         'FancyText',
         'FileBrowseButton',
         'FloatBar',  
         'FloatCanvas',
         'DynamicSashWindow',
         'EditableListBox',
         'FancyText',
         'FileBrowseButton',
         'FloatBar',  
         'FloatCanvas',
+        'FoldPanelBar',
+        'GIFAnimationCtrl',
         'HtmlWindow',
         'HtmlWindow',
+        'HyperLinkCtrl',
         'IntCtrl',
         'IntCtrl',
+        'MediaCtrl',
+        'MultiSplitterWindow',
         'MVCTree',   
         'MaskedEditControls',
         'MaskedNumCtrl',
         'MVCTree',   
         'MaskedEditControls',
         'MaskedNumCtrl',
@@ -191,7 +202,7 @@ _treeList = [
         'PythonEvents',
         'Threads',
         'Timer',
         'PythonEvents',
         'Threads',
         'Timer',
-        ##'infoframe',    # needs better explaination and some fixing
+        ##'infoframe',    # needs better explanation and some fixing
         ]),
 
     # Clipboard and DnD
         ]),
 
     # Clipboard and DnD
@@ -206,6 +217,7 @@ _treeList = [
         'ArtProvider',
         'Cursor',
         'DragImage',
         'ArtProvider',
         'Cursor',
         'DragImage',
+        'GIFAnimationCtrl',
         'Image',
         'ImageAlpha',
         'ImageFromStream',
         'Image',
         'ImageAlpha',
         'ImageFromStream',
@@ -216,11 +228,12 @@ _treeList = [
     # Other stuff
     ('Miscellaneous', [
         'ColourDB',
     # Other stuff
     ('Miscellaneous', [
         'ColourDB',
-        ##'DialogUnits',   # needs more explainations
+        ##'DialogUnits',   # needs more explanations
         'DrawXXXList',
         'FileHistory',
         'FontEnumerator',
         'Joystick',
         'DrawXXXList',
         'FileHistory',
         'FontEnumerator',
         'Joystick',
+        'MouseGestures',
         'OGL',
         'PrintFramework',
         'ShapedWindow',
         'OGL',
         'PrintFramework',
         'ShapedWindow',
@@ -316,7 +329,7 @@ class MessagePanel(wx.Panel):
         box.Add((10,10), 2)
 
         self.SetSizer(box)
         box.Add((10,10), 2)
 
         self.SetSizer(box)
-        
+        self.Fit()
         
 
 #---------------------------------------------------------------------------
         
 
 #---------------------------------------------------------------------------
@@ -514,13 +527,13 @@ except ImportError:
         def GetText(self):
             return self.GetValue()
 
         def GetText(self):
             return self.GetValue()
 
-        def GetPositionFromLine(line):
+        def GetPositionFromLine(self, line):
             return self.XYToPosition(0,line)
 
         def GotoLine(self, line):
             return self.XYToPosition(0,line)
 
         def GotoLine(self, line):
-            pos = self.editor.GetPositionFromLine(line)
-            self.editor.SetInsertionPoint(pos)
-            self.editor.ShowPosition(pos)
+            pos = self.GetPositionFromLine(line)
+            self.SetInsertionPoint(pos)
+            self.ShowPosition(pos)
 
         def SelectLine(self, line):
             start = self.GetPositionFromLine(line)
 
         def SelectLine(self, line):
             start = self.GetPositionFromLine(line)
@@ -665,7 +678,7 @@ class DemoCodePanel(wx.Panel):
             try:
                 os.makedirs(GetModifiedDirectory())
                 if not os.path.exists(GetModifiedDirectory()):
             try:
                 os.makedirs(GetModifiedDirectory())
                 if not os.path.exists(GetModifiedDirectory()):
-                    wx.LogMessage("BUG: Created demo directory but it still doesn't exit")
+                    wx.LogMessage("BUG: Created demo directory but it still doesn't exist")
                     raise AssetionError
             except:
                 wx.LogMessage("Error creating demo directory: %s" % GetModifiedDirectory())
                     raise AssetionError
             except:
                 wx.LogMessage("Error creating demo directory: %s" % GetModifiedDirectory())
@@ -926,7 +939,7 @@ class DemoErrorPanel(wx.Panel):
         self.box = wx.BoxSizer(wx.VERTICAL)
 
         # Main Label
         self.box = wx.BoxSizer(wx.VERTICAL)
 
         # Main Label
-        self.box.Add(wx.StaticText(self, -1, "An error has occured while trying to run the demo")
+        self.box.Add(wx.StaticText(self, -1, "An error has occurred while trying to run the demo")
                      , 0, wx.ALIGN_CENTER | wx.TOP, 10)
 
         # Exception Information
                      , 0, wx.ALIGN_CENTER | wx.TOP, 10)
 
         # Exception Information
@@ -1069,8 +1082,7 @@ class DemoTaskBarIcon(wx.TaskBarIcon):
 
 
     def OnTaskBarChange(self, evt):
 
 
     def OnTaskBarChange(self, evt):
-        names = [ "WXPdemo", "WXP", "Mondrian", "Test2m",
-                  "Blom08m", "Blom10m", "Blom15m" ]
+        names = [ "WXPdemo", "Mondrian", "Pencil", "Carrot" ]                  
         name = names[self.imgidx]
         
         getFunc = getattr(images, "get%sImage" % name)
         name = names[self.imgidx]
         
         getFunc = getattr(images, "get%sImage" % name)
@@ -1103,6 +1115,7 @@ class wxPythonDemo(wx.Frame):
         self.codePage = None
         self.shell = None
         self.firstTime = True
         self.codePage = None
         self.shell = None
         self.firstTime = True
+        self.finddlg = None
 
         icon = images.getWXPdemoIcon()
         self.SetIcon(icon)
 
         icon = images.getWXPdemoIcon()
         self.SetIcon(icon)
@@ -1189,9 +1202,11 @@ class wxPythonDemo(wx.Frame):
         self.Bind(wx.EVT_MENU, self.OnHelpAbout, helpItem)
         self.Bind(wx.EVT_MENU, self.OnHelpFind,  findItem)
         self.Bind(wx.EVT_MENU, self.OnFindNext,  findnextItem)
         self.Bind(wx.EVT_MENU, self.OnHelpAbout, helpItem)
         self.Bind(wx.EVT_MENU, self.OnHelpFind,  findItem)
         self.Bind(wx.EVT_MENU, self.OnFindNext,  findnextItem)
-        self.Bind(wx.EVT_COMMAND_FIND, self.OnFind)
-        self.Bind(wx.EVT_COMMAND_FIND_NEXT, self.OnFind)
-        self.Bind(wx.EVT_COMMAND_FIND_CLOSE, self.OnFindClose)
+        self.Bind(wx.EVT_FIND, self.OnFind)
+        self.Bind(wx.EVT_FIND_NEXT, self.OnFind)
+        self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
+        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateFindItems, findItem)
+        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateFindItems, findnextItem)
         self.mainmenu.Append(menu, '&Help')
         self.SetMenuBar(self.mainmenu)
 
         self.mainmenu.Append(menu, '&Help')
         self.SetMenuBar(self.mainmenu)
 
@@ -1391,7 +1406,7 @@ class wxPythonDemo(wx.Frame):
         
         # o The RunTest() for all samples must now return a window that can
         #   be palced in a tab in the main notebook.
         
         # o The RunTest() for all samples must now return a window that can
         #   be palced in a tab in the main notebook.
-        # o If an error occurs (or has occured before) an error tab is created.
+        # o If an error occurs (or has occurred before) an error tab is created.
         
         if module is not None:
             wx.LogMessage("Running demo module...")
         
         if module is not None:
             wx.LogMessage("Running demo module...")
@@ -1508,6 +1523,9 @@ class wxPythonDemo(wx.Frame):
         about.Destroy()
 
     def OnHelpFind(self, event):
         about.Destroy()
 
     def OnHelpFind(self, event):
+        if self.finddlg != None:
+            return
+        
         self.nb.SetSelection(1)
         self.finddlg = wx.FindReplaceDialog(self, self.finddata, "Find",
                         wx.FR_NOUPDOWN |
         self.nb.SetSelection(1)
         self.finddlg = wx.FindReplaceDialog(self, self.finddata, "Find",
                         wx.FR_NOUPDOWN |
@@ -1515,6 +1533,11 @@ class wxPythonDemo(wx.Frame):
                         wx.FR_NOWHOLEWORD)
         self.finddlg.Show(True)
 
                         wx.FR_NOWHOLEWORD)
         self.finddlg.Show(True)
 
+
+    def OnUpdateFindItems(self, evt):
+        evt.Enable(self.finddlg == None)
+
+
     def OnFind(self, event):
         editor = self.codePage.editor
         self.nb.SetSelection(1)
     def OnFind(self, event):
         editor = self.codePage.editor
         self.nb.SetSelection(1)
@@ -1539,6 +1562,7 @@ class wxPythonDemo(wx.Frame):
                 return
             else:
                 self.finddlg.Destroy()
                 return
             else:
                 self.finddlg.Destroy()
+                self.finddlg = None
         editor.ShowPosition(loc)
         editor.SetSelection(loc, loc + len(findstring))
 
         editor.ShowPosition(loc)
         editor.SetSelection(loc, loc + len(findstring))
 
@@ -1552,6 +1576,7 @@ class wxPythonDemo(wx.Frame):
 
     def OnFindClose(self, event):
         event.GetDialog().Destroy()
 
     def OnFindClose(self, event):
         event.GetDialog().Destroy()
+        self.finddlg = None
 
 
     def OnOpenShellWindow(self, evt):
 
 
     def OnOpenShellWindow(self, evt):
@@ -1651,18 +1676,33 @@ class wxPythonDemo(wx.Frame):
 
 class MySplashScreen(wx.SplashScreen):
     def __init__(self):
 
 class MySplashScreen(wx.SplashScreen):
     def __init__(self):
-        bmp = wx.Image(opj("bitmaps/splash.gif")).ConvertToBitmap()
+        bmp = wx.Image(opj("bitmaps/splash.png")).ConvertToBitmap()
         wx.SplashScreen.__init__(self, bmp,
                                  wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
         wx.SplashScreen.__init__(self, bmp,
                                  wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
-                                 3000, None, -1)
+                                 5000, None, -1)
         self.Bind(wx.EVT_CLOSE, self.OnClose)
         self.Bind(wx.EVT_CLOSE, self.OnClose)
+        self.fc = wx.FutureCall(2000, self.ShowMain)
+
 
     def OnClose(self, evt):
 
     def OnClose(self, evt):
+        # Make sure the default handler runs too so this window gets
+        # destroyed
+        evt.Skip()
         self.Hide()
         self.Hide()
+        
+        # if the timer is still running then go ahead and show the
+        # main frame now
+        if self.fc.IsRunning():
+            self.fc.Stop()
+            self.ShowMain()
+
+
+    def ShowMain(self):
         frame = wxPythonDemo(None, "wxPython: (A Demonstration)")
         frame.Show()
         frame = wxPythonDemo(None, "wxPython: (A Demonstration)")
         frame.Show()
-        evt.Skip()  # Make sure the default handler runs too...
-
+        if self.fc.IsRunning():
+            self.Raise()
+        
 
 class MyApp(wx.App):
     def OnInit(self):
 
 class MyApp(wx.App):
     def OnInit(self):
@@ -1671,6 +1711,8 @@ class MyApp(wx.App):
         the main frame when it is time to do so.
         """
 
         the main frame when it is time to do so.
         """
 
+        wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
+
         # For debugging
         #self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
 
         # For debugging
         #self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
 
@@ -1679,7 +1721,7 @@ class MyApp(wx.App):
         # initialization, finally creating and showing the main
         # application window(s).  In this case we have nothing else to
         # do so we'll delay showing the main frame until later (see
         # initialization, finally creating and showing the main
         # application window(s).  In this case we have nothing else to
         # do so we'll delay showing the main frame until later (see
-        # OnClose above) so the users can see the SplashScreen effect.        
+        # ShowMain above) so the users can see the SplashScreen effect.        
         splash = MySplashScreen()
         splash.Show()
 
         splash = MySplashScreen()
         splash.Show()