]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/FloatCanvas.py
default style for statusbars varies by platform
[wxWidgets.git] / wxPython / demo / FloatCanvas.py
index 953fb0800bada3c47dff378031091a096ddc33b3..9fe43d606e7eb0b727801fa0fc147c9415cb05e5 100644 (file)
@@ -1,8 +1,7 @@
 
-from wxPython.wx  import *
+import  wx
 
-
-## Stuff to integrate FloatCanvas into wxPython Demo
+# Stuff to integrate FloatCanvas into wxPython Demo
 try:
     import Numeric
     haveNumeric = True
@@ -17,43 +16,35 @@ You can get it at:
      http://sourceforge.net/projects/numpy
 """     
     def runTest(frame, nb, log):
-        dlg = wxMessageDialog(frame, errorText, 
-                              'Sorry', wxOK | wxICON_INFORMATION)
+        dlg = wx.MessageDialog(
+                frame, errorText, 'Sorry', wx.OK | wx.ICON_INFORMATION
+                )
+
         dlg.ShowModal()
         dlg.Destroy()
 
     overview = ""
 
 else:
-    def runTest(frame, nb, log):
-        """
-        This method is used by the wxPython Demo Framework for integrating
-        this demo with the rest.
-        """
-        win = DrawFrame(NULL, -1, "FloatCanvas Drawing Window",wxDefaultPosition,wxSize(500,500))
-        frame.otherWin = win
-        win.Show(True)
-
-
-
     from wxPython.lib import floatcanvas
     import wxPython.lib.colourdb
     
-    ID_ABOUT_MENU = wxNewId()          
-    ID_EXIT_MENU  = wxNewId() 
-    ID_ZOOM_TO_FIT_MENU = wxNewId()
-    ID_DRAWTEST_MENU = wxNewId()
-    ID_LINETEST_MENU = wxNewId()
-    ID_DRAWMAP_MENU = wxNewId()
-    ID_DRAWMAP2_MENU = wxNewId()
-    ID_CLEAR_MENU = wxNewId()
+    ID_ABOUT_MENU = wx.NewId()          
+    ID_EXIT_MENU  = wx.NewId() 
+    ID_ZOOM_TO_FIT_MENU = wx.NewId()
+    ID_DRAWTEST_MENU = wx.NewId()
+    ID_LINETEST_MENU = wx.NewId()
+    ID_DRAWMAP_MENU = wx.NewId()
+    ID_DRAWMAP2_MENU = wx.NewId()
+    ID_CLEAR_MENU = wx.NewId()
 
-    wxPython.lib.colourdb.updateColourDB()
-    colors = wxPython.lib.colourdb.getColourList()
 
+    colors = []
     LineStyles = floatcanvas.draw_object.LineStyleList.keys()
+
+
     
-    class DrawFrame(wxFrame):
+    class DrawFrame(wx.Frame):
     
         """
     
@@ -61,39 +52,38 @@ else:
         
         """
         
-        def __init__(self,parent, id,title,position,size):
-            wxFrame.__init__(self,parent, id,title,position, size)
+        def __init__(self, parent, id, title, position, size):
+            wx.Frame.__init__(self,parent, id,title,position, size)
             
-            ## Set up the MenuBar
+            # Set up the MenuBar
             
-            MenuBar = wxMenuBar()
+            MenuBar = wx.MenuBar()
             
-            file_menu = wxMenu()
+            file_menu = wx.Menu()
             file_menu.Append(ID_EXIT_MENU, "&Close","Close this frame")
-            EVT_MENU(self, ID_EXIT_MENU,       self.OnQuit)
+            self.Bind(wx.EVT_MENU, self.OnQuit, id=ID_EXIT_MENU)
             MenuBar.Append(file_menu, "&File")
             
-            draw_menu = wxMenu()
+            draw_menu = wx.Menu()
             draw_menu.Append(ID_DRAWTEST_MENU, "&Draw Test","Run a test of drawing random components")
-            EVT_MENU(self, ID_DRAWTEST_MENU,self.DrawTest)
+            self.Bind(wx.EVT_MENU, self.DrawTest, id=ID_DRAWTEST_MENU)
             draw_menu.Append(ID_LINETEST_MENU, "&Line Test","Run a test of drawing random lines")
-            EVT_MENU(self, ID_LINETEST_MENU,self.LineTest)
+            self.Bind(wx.EVT_MENU, self.LineTest, id=ID_LINETEST_MENU)
             draw_menu.Append(ID_DRAWMAP_MENU, "Draw &Map","Run a test of drawing a map")
-            EVT_MENU(self, ID_DRAWMAP_MENU,self.DrawMap)
+            self.Bind(wx.EVT_MENU, self.DrawMap, id=ID_DRAWMAP_MENU)
             draw_menu.Append(ID_CLEAR_MENU, "&Clear","Clear the Canvas")
-            EVT_MENU(self, ID_CLEAR_MENU,self.Clear)
+            self.Bind(wx.EVT_MENU, self.Clear, id=ID_CLEAR_MENU)
             MenuBar.Append(draw_menu, "&Draw")
-            
-            
-            view_menu = wxMenu()
+
+            view_menu = wx.Menu()
             view_menu.Append(ID_ZOOM_TO_FIT_MENU, "Zoom to &Fit","Zoom to fit the window")
-            EVT_MENU(self, ID_ZOOM_TO_FIT_MENU,self.ZoomToFit)
+            self.Bind(wx.EVT_MENU, self.ZoomToFit, id=ID_ZOOM_TO_FIT_MENU)
             MenuBar.Append(view_menu, "&View")
             
-            help_menu = wxMenu()
+            help_menu = wx.Menu()
             help_menu.Append(ID_ABOUT_MENU, "&About",
                                     "More information About this program")
-            EVT_MENU(self, ID_ABOUT_MENU,      self.OnAbout)
+            self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_ABOUT_MENU)
             MenuBar.Append(help_menu, "&Help")
             
             self.SetMenuBar(MenuBar)
@@ -101,15 +91,15 @@ else:
             self.CreateStatusBar()
             self.SetStatusText("")
             
-            EVT_CLOSE(self, self.OnCloseWindow)
+            self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
             
             # Other event handlers:
-            EVT_RIGHT_DOWN(self, self.RightButtonEvent)
+            self.Bind(wx.EVT_RIGHT_DOWN, self.RightButtonEvent)
             
             # Add the Canvas
             self.Canvas = floatcanvas.FloatCanvas(self,-1,(500,500),
                                       ProjectionFun = 'FlatEarth',
-                                      Debug = 1,
+                                      Debug = 0,
                                       EnclosingFrame = self,
                                       BackgroundColor = "DARK SLATE BLUE",
                                       UseBackground = 0,
@@ -126,20 +116,24 @@ else:
             event.Skip()
             
         def OnAbout(self, event):
-            dlg = wxMessageDialog(self, "This is a small program to demonstrate\n"
+            dlg = wx.MessageDialog(self, "This is a small program to demonstrate\n"
                                                       "the use of the FloatCanvas\n",
-                                                      "About Me", wxOK | wxICON_INFORMATION)
+                                                      "About Me", wx.OK | wx.ICON_INFORMATION)
             dlg.ShowModal()
             dlg.Destroy()
             
         def SetMode(self,event):
             for id in [ID_ZOOM_IN_BUTTON,ID_ZOOM_OUT_BUTTON,ID_MOVE_MODE_BUTTON]:
                 self.ToolBar.ToggleTool(id,0)
+                
             self.ToolBar.ToggleTool(event.GetId(),1)
+
             if event.GetId() == ID_ZOOM_IN_BUTTON:
                 self.Canvas.SetGUIMode("ZoomIn")
+
             elif event.GetId() == ID_ZOOM_OUT_BUTTON:
                 self.Canvas.SetGUIMode("ZoomOut")
+
             elif event.GetId() == ID_MOVE_MODE_BUTTON:
                 self.Canvas.SetGUIMode("Move")
                 
@@ -158,15 +152,17 @@ else:
             self.Destroy()
             
         def DrawTest(self,event):
-            wxGetApp().Yield()
+            wx.GetApp().Yield()
+
             import random
             import RandomArray
+
             Range = (-10,10)
             
             Canvas = self.Canvas
             object_list = self.object_list
             
-            ##         Random tests of everything:
+            #          Random tests of everything:
             
             # Rectangles
             for i in range(5):
@@ -251,7 +247,7 @@ else:
             self.Canvas.ZoomToBB()
             
         def DrawMap(self,event = None):
-            wxGetApp().Yield()
+            wx.GetApp().Yield()
             import os, time
         ## Test of Actual Map Data
             self.Clear()
@@ -296,7 +292,7 @@ else:
     ##        print "It took %f seconds to draw %i lines"%(time.clock() - start,len(linepoints) )
     
         def LineTest(self,event = None):
-            wxGetApp().Yield()
+            wx.GetApp().Yield()
             import os, time
             import random
             Range = (-10,10)
@@ -321,7 +317,7 @@ else:
             self.Canvas.ZoomToBB()
             print "It took %f seconds to draw %i lines"%(time.clock() - start,len(linepoints) )
     
-    class DemoApp(wxApp):
+    class DemoApp(wx.App):
         """
         How the demo works:
         
@@ -372,7 +368,12 @@ else:
         """
         
         def OnInit(self):
-            frame = DrawFrame(NULL, -1, "FloatCanvas Demo App",wxDefaultPosition,wxSize(700,700))
+            global colors
+            wxPython.lib.colourdb.updateColourDB()
+            colors = wxPython.lib.colourdb.getColourList()
+            
+            frame = DrawFrame(None, -1, "FloatCanvas Demo App",
+                              wx.DefaultPosition, (700,700))
     
             self.SetTopWindow(frame)
     
@@ -427,15 +428,42 @@ else:
             return Lines
         else:
             return Shorelines
+
+
+    #----------------------------------------------------------------------
+    
+    def runTest(frame, nb, log):
+        """
+        This method is used by the wxPython Demo Framework for integrating
+        this demo with the rest.
+        """
+        global colors
+        wxPython.lib.colourdb.updateColourDB()
+        colors = wxPython.lib.colourdb.getColourList()
+
+        win = DrawFrame(None, -1, "FloatCanvas Drawing Window",
+                        wx.DefaultPosition, (500,500))
+        frame.otherWin = win
+        win.Show(True)
+
+
+
     
     ## for the wxPython demo:
     overview = floatcanvas.FloatCanvas.__doc__
+
+
       
 if __name__ == "__main__":
     if not haveNumeric:
         print errorText
     else:
         app = DemoApp(0)
+
+        import  wx.lib.colourdb
+        wx.lib.colourdb.updateColourDB()
+        colors = wx.lib.colourdb.getColourList()
+
         app.MainLoop()