Rev 584 | Rev 586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
584 | FredericG | 1 | #!/usr/bin/env python |
2 | # -*- coding: iso-8859-15 -*- |
||
3 | # generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009 |
||
4 | |||
5 | import wx |
||
585 | FredericG | 6 | import wx.lib |
7 | import wx.lib.plot |
||
584 | FredericG | 8 | |
585 | FredericG | 9 | # Needs Numeric or numarray or NumPy |
10 | try: |
||
11 | import numpy.oldnumeric as _Numeric |
||
12 | except: |
||
13 | try: |
||
14 | import numarray as _Numeric #if numarray is used it is renamed Numeric |
||
15 | except: |
||
16 | try: |
||
17 | import Numeric as _Numeric |
||
18 | except: |
||
19 | msg= """ |
||
20 | This module requires the Numeric/numarray or NumPy module, |
||
21 | which could not be imported. It probably is not installed |
||
22 | (it's not part of the standard Python distribution). See the |
||
23 | Numeric Python site (http://numpy.scipy.org) for information on |
||
24 | downloading source or binaries.""" |
||
25 | raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg |
||
26 | |||
584 | FredericG | 27 | # begin wxGlade: extracode |
28 | # end wxGlade |
||
29 | |||
30 | |||
31 | |||
585 | FredericG | 32 | class wxFrame(wx.Panel): |
33 | def __init__(self, *args, **kwds): |
||
34 | # begin wxGlade: wxFrame.__init__ |
||
35 | kwds["style"] = wx.TAB_TRAVERSAL |
||
36 | wx.Panel.__init__(self, *args, **kwds) |
||
37 | |||
38 | self.__set_properties() |
||
39 | self.__do_layout() |
||
40 | # end wxGlade |
||
41 | |||
42 | def __set_properties(self): |
||
43 | # begin wxGlade: wxFrame.__set_properties |
||
44 | pass |
||
45 | # end wxGlade |
||
46 | |||
47 | def __do_layout(self): |
||
48 | # begin wxGlade: wxFrame.__do_layout |
||
49 | pass |
||
50 | # end wxGlade |
||
51 | |||
52 | # end of class wxFrame |
||
53 | |||
54 | |||
55 | class MyFrame(wx.Frame): |
||
56 | def __init__(self, *args, **kwds): |
||
57 | # content of this block not found: did you rename this class? |
||
58 | pass |
||
59 | |||
60 | def __set_properties(self): |
||
61 | # content of this block not found: did you rename this class? |
||
62 | pass |
||
63 | |||
64 | def __do_layout(self): |
||
65 | # content of this block not found: did you rename this class? |
||
66 | pass |
||
67 | |||
68 | # end of class MyFrame |
||
69 | |||
70 | |||
584 | FredericG | 71 | class MainFrame(wx.Frame): |
72 | def __init__(self, *args, **kwds): |
||
73 | # begin wxGlade: MainFrame.__init__ |
||
74 | kwds["style"] = wx.DEFAULT_FRAME_STYLE |
||
75 | wx.Frame.__init__(self, *args, **kwds) |
||
76 | self.Port = wx.StaticText(self, -1, "Port") |
||
77 | self.text_ctrl_1 = wx.TextCtrl(self, -1, "") |
||
78 | self.label_5 = wx.StaticText(self, -1, "label_5") |
||
79 | self.text_ctrl_5 = wx.TextCtrl(self, -1, "") |
||
80 | self.label_2 = wx.StaticText(self, -1, "Motor(s)") |
||
81 | self.text_ctrl_2 = wx.TextCtrl(self, -1, "") |
||
82 | self.label_6 = wx.StaticText(self, -1, "label_6") |
||
83 | self.text_ctrl_6 = wx.TextCtrl(self, -1, "") |
||
84 | self.label_3 = wx.StaticText(self, -1, "Channel(s)") |
||
85 | self.text_ctrl_3 = wx.TextCtrl(self, -1, "") |
||
86 | self.label_7 = wx.StaticText(self, -1, "label_7") |
||
87 | self.text_ctrl_7 = wx.TextCtrl(self, -1, "") |
||
88 | self.label_4 = wx.StaticText(self, -1, "Speed(s)") |
||
89 | self.text_ctrl_4 = wx.TextCtrl(self, -1, "") |
||
90 | self.label_8 = wx.StaticText(self, -1, "label_8") |
||
91 | self.text_ctrl_8 = wx.TextCtrl(self, -1, "") |
||
92 | self.button_1 = wx.Button(self, -1, "button_1") |
||
585 | FredericG | 93 | self.GraphFanel = wx.Panel(self, -1) |
94 | self.panel_1 = wxFrame(self, -1) |
||
584 | FredericG | 95 | |
96 | self.__set_properties() |
||
97 | self.__do_layout() |
||
98 | # end wxGlade |
||
99 | |||
585 | FredericG | 100 | |
101 | |||
584 | FredericG | 102 | def __set_properties(self): |
103 | # begin wxGlade: MainFrame.__set_properties |
||
104 | self.SetTitle("frame_1") |
||
585 | FredericG | 105 | self.GraphFanel.SetMinSize((800,300)) |
584 | FredericG | 106 | # end wxGlade |
107 | |||
108 | def __do_layout(self): |
||
109 | # begin wxGlade: MainFrame.__do_layout |
||
110 | sizer_1 = wx.BoxSizer(wx.VERTICAL) |
||
111 | grid_sizer_1 = wx.GridSizer(5, 4, 4, 4) |
||
112 | grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0) |
||
113 | grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0) |
||
114 | grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0) |
||
115 | grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0) |
||
116 | grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0) |
||
117 | grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0) |
||
118 | grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0) |
||
119 | grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0) |
||
120 | grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0) |
||
121 | grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0) |
||
122 | grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0) |
||
123 | grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0) |
||
124 | grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0) |
||
125 | grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0) |
||
126 | grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0) |
||
127 | grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0) |
||
128 | grid_sizer_1.Add(self.button_1, 0, 0, 0) |
||
129 | sizer_1.Add(grid_sizer_1, 0, 0, 2) |
||
585 | FredericG | 130 | sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0) |
131 | sizer_1.Add(self.panel_1, 1, wx.ALL|wx.EXPAND, 0) |
||
584 | FredericG | 132 | self.SetSizer(sizer_1) |
133 | sizer_1.Fit(self) |
||
134 | self.Layout() |
||
135 | # end wxGlade |
||
136 | |||
585 | FredericG | 137 | |
138 | self.client = wx.lib.plot.PlotCanvas(self.GraphFanel) |
||
139 | #define the function for drawing pointLabels |
||
140 | self.client.SetPointLabelFunc(self.DrawPointLabel) |
||
141 | |||
142 | self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL)) |
||
143 | self.client.SetFontSizeAxis(10) |
||
144 | self.client.SetFontSizeLegend(7) |
||
145 | self.client.setLogScale((False,False)) |
||
146 | self.client.SetXSpec('auto') |
||
147 | self.client.SetYSpec('auto') |
||
148 | |||
149 | data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200. |
||
150 | data1.shape = (100, 2) |
||
151 | data1[:,1] = _Numeric.sin(data1[:,0]) |
||
152 | markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1) |
||
153 | pi = 3.1415 |
||
154 | markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), |
||
155 | (3.*pi/4., -1)], legend='Cross Legend', colour='blue', |
||
156 | marker='cross') |
||
157 | self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis")) |
||
158 | |||
159 | def DrawPointLabel(self, dc, mDataDict): |
||
160 | """This is the fuction that defines how the pointLabels are plotted |
||
161 | dc - DC that will be passed |
||
162 | mDataDict - Dictionary of data that you want to use for the pointLabel |
||
163 | |||
164 | As an example I have decided I want a box at the curve point |
||
165 | with some text information about the curve plotted below. |
||
166 | Any wxDC method can be used. |
||
167 | """ |
||
168 | # ---------- |
||
169 | dc.SetPen(wx.Pen(wx.BLACK)) |
||
170 | dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) ) |
||
171 | |||
172 | sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point |
||
173 | dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point |
||
174 | px,py = mDataDict["pointXY"] |
||
175 | cNum = mDataDict["curveNum"] |
||
176 | pntIn = mDataDict["pIndex"] |
||
177 | legend = mDataDict["legend"] |
||
178 | #make a string to display |
||
179 | s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn) |
||
180 | dc.DrawText(s, sx , sy+1) |
||
181 | # ----------- |
||
182 | |||
584 | FredericG | 183 | # end of class MainFrame |
184 | |||
185 | |||
186 | class App(wx.App): |
||
187 | def OnInit(self): |
||
188 | wx.InitAllImageHandlers() |
||
189 | frame_1 = MainFrame(None, -1, "") |
||
190 | self.SetTopWindow(frame_1) |
||
191 | frame_1.Show() |
||
192 | return 1 |
||
193 | |||
194 | # end of class App |
||
195 | |||
196 | if __name__ == "__main__": |
||
197 | VibrationTestGui = App(0) |
||
198 | VibrationTestGui.MainLoop() |