]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/PyPlot.py
Warning fixes and source cleaning.
[wxWidgets.git] / wxPython / demo / PyPlot.py
index 2281057b76f3e6ba90dee11d00a30d19d9c12637..52387c5044ef0daa860dc740d34c0826a1f05643 100644 (file)
@@ -1,6 +1,12 @@
 
 import  wx
-import  wx.lib.plot
+
+hadImportError = False
+try:
+    import  wx.lib.plot
+except ImportError:
+    hadImportError = True
+    
 
 ################################################################\
 # Where's the code???                                           |
@@ -13,18 +19,46 @@ import  wx.lib.plot
 # the file, as expected.                                        |
 ################################################################/
 
-#----------------------------------------------------------------------
+#---------------------------------------------------------------------------
+
+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 PyPlot sample", (50,50))
+        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
+
+
+    def OnButton(self, evt):
+        win = wx.lib.plot.TestFrame(self, -1, "PlotCanvas Demo")
+        win.Show()
+
+#---------------------------------------------------------------------------
+
 
 def runTest(frame, nb, log):
-    # Loading the demo class directly from the library's
-    # test code.
-    win = wx.lib.plot.TestFrame(nb, -1, "PlotCanvas Demo")
-    frame.otherWin = win
-    return None
+    if not hadImportError:
+        win = TestPanel(nb, log)
+    else:
+        from Main import MessagePanel
+        win = MessagePanel(nb, """\
+This demo requires the Numeric or numarray module,
+which could not be imported.  It probably is not installed
+(it's not part of the standard Python distribution). See the
+Python site (http://www.python.org) for information on
+downloading source or binaries.""",
+                           'Sorry', wx.ICON_WARNING)
+    
+    return win
+
 
 #----------------------------------------------------------------------
 
-overview = """\
+if hadImportError:
+    overview = ""
+else:
+    overview = """\
 <html><body>
 <center><h2>PyPlot</h2></center>