]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/PyPlot.py
docstring update
[wxWidgets.git] / wxPython / demo / PyPlot.py
CommitLineData
9d6685e2
RD
1
2import wx
59c24dcb
RD
3
4hadImportError = False
5try:
6 import wx.lib.plot
7except ImportError:
8 hadImportError = True
9
9d6685e2
RD
10
11################################################################\
12# Where's the code??? |
13# |
14# wx.lib.plot.py came with its own excellent demo built in, |
15# for testing purposes, but it serves quite well to demonstrate |
16# the code and classes within, so we are simply borrowing that |
60d8ee39 17# code for the demo. Please load up wx.lib.plot.py for a review |
9d6685e2
RD
18# of the code itself. The demo/test is at the bottom of |
19# the file, as expected. |
20################################################################/
21
5523df9f
RD
22#---------------------------------------------------------------------------
23
24class TestPanel(wx.Panel):
25 def __init__(self, parent, log):
26 self.log = log
27 wx.Panel.__init__(self, parent, -1)
28
29 b = wx.Button(self, -1, "Show the PyPlot sample", (50,50))
30 self.Bind(wx.EVT_BUTTON, self.OnButton, b)
31
32
33 def OnButton(self, evt):
34 win = wx.lib.plot.TestFrame(self, -1, "PlotCanvas Demo")
35 win.Show()
36
37#---------------------------------------------------------------------------
38
9d6685e2
RD
39
40def runTest(frame, nb, log):
59c24dcb
RD
41 if not hadImportError:
42 win = TestPanel(nb, log)
43 else:
44 from Main import MessagePanel
45 win = MessagePanel(nb, """\
46This demo requires the Numeric or numarray module,
47which could not be imported. It probably is not installed
48(it's not part of the standard Python distribution). See the
49Python site (http://www.python.org) for information on
50downloading source or binaries.""",
51 'Sorry', wx.ICON_WARNING)
52
5523df9f
RD
53 return win
54
9d6685e2
RD
55
56#----------------------------------------------------------------------
57
59c24dcb
RD
58if hadImportError:
59 overview = ""
60else:
61 overview = """\
9d6685e2
RD
62<html><body>
63<center><h2>PyPlot</h2></center>
64
65This demo illustrates the features of the new PyPlot modules, found
66in wx.lib.plot.py. All methods and functions are documented clearly
67therein; only the overview is included here.
68
69<p>
70PyPlot is an improvement over wxPlotCanvas, which is now deprecated.
71If you are using wxPlotCanvas now, please make plans to migrate in
72anticipation of the time that wxPlotCanvas disappears completely.
73
74<p>
75The demo illustrates four different plot styles (with appropriate
76variations on fonts, etc, to show how flexible it is) as well as
77provides you with a means to tinker with all the features that
78come with the class itself.
79
80<p><ul>
81<li>File Menu
82
83 <ul>
84 <li>Page Setup
85
60d8ee39 86 <p>This allows you to set up how the plot will be printed. This
9d6685e2
RD
87 is built into the library itself.
88
89 <li>Print Preview
90
60d8ee39 91 <p>As you might expect, this allows you to preview how the plot
9d6685e2
RD
92 will look when printed, in light of the page setup you may
93 have selected above.
94
95 <li>Print
96
653d2f0c 97 <p>Surprise! It prints the current plot to your printer! :-)
9d6685e2
RD
98
99 <li>Save Plot
100
60d8ee39 101 <p>That's right, the library even provides you with the means
9d6685e2
RD
102 to export the plotted data out to a graphics file. Several
103 formats are allowed for, basically any image class that
104 supports saving.
105 </ul>
106
107<li>Plot Menu
108
109 <ul>
110 <li>Plot 1 ... Plot 5
111
60d8ee39 112 <p>Different data with different plot formats, including one empty
9d6685e2
RD
113 plot.
114
115 <li>Enable Zoom
116
60d8ee39 117 <p>If Zoom is enabled, you can rubber-band select an area of the
9d6685e2
RD
118 plot to examine it in detail using the left mouse button. Right
119 mouse button zooms back out. This is automatically supported
120 by the library, all you have to do is turn it on.
121
122 <li>Enable Grid
123
60d8ee39 124 <p>Plots can have different styles of grids, and and these grids can
9d6685e2
RD
125 be turned on or off as needed.
126
127 <li>Enable Legend
128
60d8ee39 129 <p>Plot can have legends or not, the contents which are definable
9d6685e2
RD
130 by you.
131 </ul>
132</ul>
133
134<HR><pre>
135%s</pre>
136</body></html>
137""" % wx.lib.plot.__doc__
138
139
140if __name__ == '__main__':
141 import sys,os
142 import run
8eca4fef 143 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
9d6685e2 144