Go to most recent revision | Details | 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 | |||
586 | FredericG | 5 | import sys |
584 | FredericG | 6 | import wx |
585 | FredericG | 7 | import wx.lib |
8 | import wx.lib.plot |
||
584 | FredericG | 9 | |
585 | FredericG | 10 | # Needs Numeric or numarray or NumPy |
11 | try: |
||
12 | import numpy.oldnumeric as _Numeric |
||
13 | except: |
||
14 | try: |
||
15 | import numarray as _Numeric #if numarray is used it is renamed Numeric |
||
16 | except: |
||
17 | try: |
||
18 | import Numeric as _Numeric |
||
19 | except: |
||
20 | msg= """ |
||
21 | This module requires the Numeric/numarray or NumPy module, |
||
22 | which could not be imported. It probably is not installed |
||
23 | (it's not part of the standard Python distribution). See the |
||
24 | Numeric Python site (http://numpy.scipy.org) for information on |
||
25 | downloading source or binaries.""" |
||
26 | raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg |
||
27 | |||
584 | FredericG | 28 | # begin wxGlade: extracode |
29 | # end wxGlade |
||
30 | |||
31 | |||
32 | |||
587 | FredericG | 33 | class MenuBar(wx.MenuBar): |
34 | def __init__(self, *args, **kwds): |
||
35 | # content of this block not found: did you rename this class? |
||
36 | pass |
||
37 | |||
38 | def __set_properties(self): |
||
39 | # content of this block not found: did you rename this class? |
||
40 | pass |
||
41 | |||
42 | def __do_layout(self): |
||
43 | # content of this block not found: did you rename this class? |
||
44 | pass |
||
45 | |||
46 | # end of class MenuBar |
||
47 | |||
48 | |||
585 | FredericG | 49 | class wxFrame(wx.Panel): |
50 | def __init__(self, *args, **kwds): |
||
586 | FredericG | 51 | # content of this block not found: did you rename this class? |
52 | pass |
||
585 | FredericG | 53 | |
54 | def __set_properties(self): |
||
586 | FredericG | 55 | # content of this block not found: did you rename this class? |
585 | FredericG | 56 | pass |
57 | |||
58 | def __do_layout(self): |
||
586 | FredericG | 59 | # content of this block not found: did you rename this class? |
585 | FredericG | 60 | pass |
61 | |||
62 | # end of class wxFrame |
||
63 | |||
64 | |||
65 | class MyFrame(wx.Frame): |
||
66 | def __init__(self, *args, **kwds): |
||
67 | # content of this block not found: did you rename this class? |
||
68 | pass |
||
69 | |||
70 | def __set_properties(self): |
||
71 | # content of this block not found: did you rename this class? |
||
72 | pass |
||
73 | |||
74 | def __do_layout(self): |
||
75 | # content of this block not found: did you rename this class? |
||
76 | pass |
||
77 | |||
78 | # end of class MyFrame |
||
79 | |||
80 | |||
584 | FredericG | 81 | class MainFrame(wx.Frame): |
82 | def __init__(self, *args, **kwds): |
||
83 | # begin wxGlade: MainFrame.__init__ |
||
84 | kwds["style"] = wx.DEFAULT_FRAME_STYLE |
||
85 | wx.Frame.__init__(self, *args, **kwds) |
||
587 | FredericG | 86 | |
87 | # Menu Bar |
||
88 | self.frame_1_menubar = wx.MenuBar() |
||
89 | wxglade_tmp_menu = wx.Menu() |
||
90 | wxglade_tmp_menu.Append(wx.NewId(), "Exit", "", wx.ITEM_NORMAL) |
||
91 | self.frame_1_menubar.Append(wxglade_tmp_menu, "File") |
||
92 | wxglade_tmp_menu = wx.Menu() |
||
93 | wxglade_tmp_menu.Append(wx.NewId(), "Clear", "", wx.ITEM_NORMAL) |
||
94 | wxglade_tmp_menu.Append(wx.NewId(), "Import", "", wx.ITEM_NORMAL) |
||
95 | self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet") |
||
96 | wxglade_tmp_menu = wx.Menu() |
||
97 | self.frame_1_menubar.Append(wxglade_tmp_menu, "MK") |
||
98 | wxglade_tmp_menu = wx.Menu() |
||
99 | self.frame_1_menubar.Append(wxglade_tmp_menu, "Help") |
||
100 | self.SetMenuBar(self.frame_1_menubar) |
||
101 | # Menu Bar end |
||
584 | FredericG | 102 | self.Port = wx.StaticText(self, -1, "Port") |
103 | self.text_ctrl_1 = wx.TextCtrl(self, -1, "") |
||
104 | self.label_5 = wx.StaticText(self, -1, "label_5") |
||
105 | self.text_ctrl_5 = wx.TextCtrl(self, -1, "") |
||
106 | self.label_2 = wx.StaticText(self, -1, "Motor(s)") |
||
107 | self.text_ctrl_2 = wx.TextCtrl(self, -1, "") |
||
108 | self.label_6 = wx.StaticText(self, -1, "label_6") |
||
109 | self.text_ctrl_6 = wx.TextCtrl(self, -1, "") |
||
110 | self.label_3 = wx.StaticText(self, -1, "Channel(s)") |
||
111 | self.text_ctrl_3 = wx.TextCtrl(self, -1, "") |
||
112 | self.label_7 = wx.StaticText(self, -1, "label_7") |
||
113 | self.text_ctrl_7 = wx.TextCtrl(self, -1, "") |
||
114 | self.label_4 = wx.StaticText(self, -1, "Speed(s)") |
||
115 | self.text_ctrl_4 = wx.TextCtrl(self, -1, "") |
||
116 | self.label_8 = wx.StaticText(self, -1, "label_8") |
||
117 | self.text_ctrl_8 = wx.TextCtrl(self, -1, "") |
||
118 | self.button_1 = wx.Button(self, -1, "button_1") |
||
585 | FredericG | 119 | self.GraphFanel = wx.Panel(self, -1) |
586 | FredericG | 120 | self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) |
584 | FredericG | 121 | |
122 | self.__set_properties() |
||
123 | self.__do_layout() |
||
587 | FredericG | 124 | |
125 | self.Bind(wx.EVT_MENU, self.OnImport, id=-1) |
||
584 | FredericG | 126 | # end wxGlade |
127 | |||
587 | FredericG | 128 | def setApp(self, app): |
129 | self.app = app |
||
585 | FredericG | 130 | |
584 | FredericG | 131 | def __set_properties(self): |
132 | # begin wxGlade: MainFrame.__set_properties |
||
587 | FredericG | 133 | self.SetTitle("VibrationTest") |
585 | FredericG | 134 | self.GraphFanel.SetMinSize((800,300)) |
584 | FredericG | 135 | # end wxGlade |
136 | |||
137 | def __do_layout(self): |
||
138 | # begin wxGlade: MainFrame.__do_layout |
||
139 | sizer_1 = wx.BoxSizer(wx.VERTICAL) |
||
586 | FredericG | 140 | grid_sizer_2 = wx.GridSizer(2, 1, 4, 4) |
584 | FredericG | 141 | grid_sizer_1 = wx.GridSizer(5, 4, 4, 4) |
142 | grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0) |
||
143 | grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0) |
||
144 | grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0) |
||
145 | grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0) |
||
146 | grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0) |
||
147 | grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0) |
||
148 | grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0) |
||
149 | grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0) |
||
150 | grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0) |
||
151 | grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0) |
||
152 | grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0) |
||
153 | grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0) |
||
154 | grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0) |
||
155 | grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0) |
||
156 | grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0) |
||
157 | grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0) |
||
158 | grid_sizer_1.Add(self.button_1, 0, 0, 0) |
||
159 | sizer_1.Add(grid_sizer_1, 0, 0, 2) |
||
585 | FredericG | 160 | sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0) |
586 | FredericG | 161 | grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0) |
162 | sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0) |
||
584 | FredericG | 163 | self.SetSizer(sizer_1) |
164 | sizer_1.Fit(self) |
||
165 | self.Layout() |
||
166 | # end wxGlade |
||
167 | |||
586 | FredericG | 168 | # Configure Graph |
585 | FredericG | 169 | self.client = wx.lib.plot.PlotCanvas(self.GraphFanel) |
170 | self.client.SetPointLabelFunc(self.DrawPointLabel) |
||
171 | |||
172 | self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL)) |
||
173 | self.client.SetFontSizeAxis(10) |
||
174 | self.client.SetFontSizeLegend(7) |
||
175 | self.client.setLogScale((False,False)) |
||
176 | self.client.SetXSpec('auto') |
||
177 | self.client.SetYSpec('auto') |
||
178 | |||
179 | data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200. |
||
180 | data1.shape = (100, 2) |
||
181 | data1[:,1] = _Numeric.sin(data1[:,0]) |
||
182 | markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1) |
||
183 | pi = 3.1415 |
||
184 | markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), |
||
185 | (3.*pi/4., -1)], legend='Cross Legend', colour='blue', |
||
186 | marker='cross') |
||
187 | self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis")) |
||
586 | FredericG | 188 | |
189 | # Configure TestListCtrl |
||
190 | self.TestListCtrl.InsertColumn(0, "Name") |
||
191 | self.TestListCtrl.InsertColumn(1, "Result") |
||
192 | |||
585 | FredericG | 193 | def DrawPointLabel(self, dc, mDataDict): |
194 | """This is the fuction that defines how the pointLabels are plotted |
||
195 | dc - DC that will be passed |
||
196 | mDataDict - Dictionary of data that you want to use for the pointLabel |
||
197 | |||
198 | As an example I have decided I want a box at the curve point |
||
199 | with some text information about the curve plotted below. |
||
200 | Any wxDC method can be used. |
||
201 | """ |
||
202 | # ---------- |
||
203 | dc.SetPen(wx.Pen(wx.BLACK)) |
||
204 | dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) ) |
||
205 | |||
206 | sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point |
||
207 | dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point |
||
208 | px,py = mDataDict["pointXY"] |
||
209 | cNum = mDataDict["curveNum"] |
||
210 | pntIn = mDataDict["pIndex"] |
||
211 | legend = mDataDict["legend"] |
||
212 | #make a string to display |
||
213 | s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn) |
||
214 | dc.DrawText(s, sx , sy+1) |
||
215 | # ----------- |
||
216 | |||
587 | FredericG | 217 | def OnImport(self, event): # wxGlade: MainFrame.<event_handler> |
218 | self.app.Import() |
||
219 | |||
584 | FredericG | 220 | # end of class MainFrame |
221 | |||
222 | |||
586 | FredericG | 223 | class VibTest: |
224 | def __init__(self, name, rawData): |
||
225 | self.name = name |
||
226 | self.rawData = rawData |
||
227 | |||
587 | FredericG | 228 | |
584 | FredericG | 229 | class App(wx.App): |
586 | FredericG | 230 | def __init__(self, par): |
231 | self.VibTests = [] |
||
232 | |||
233 | wx.App.__init__(self, par) |
||
234 | |||
235 | |||
236 | def AddTest(self, name, rawData): |
||
237 | test = VibTest(name, rawData) |
||
238 | self.VibTests.append(test) |
||
239 | |||
240 | index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name) |
||
241 | self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK") |
||
242 | |||
584 | FredericG | 243 | def OnInit(self): |
244 | wx.InitAllImageHandlers() |
||
586 | FredericG | 245 | self.frame_1 = MainFrame(None, -1, "") |
587 | FredericG | 246 | self.frame_1.setApp(self); |
586 | FredericG | 247 | self.SetTopWindow(self.frame_1) |
248 | |||
587 | FredericG | 249 | self.frame_1.Show() |
250 | return 1 |
||
251 | |||
252 | def Import(self): |
||
253 | print "Import" |
||
586 | FredericG | 254 | self.AddTest("Test1", range(0,1000)) |
255 | self.AddTest("Test2", range(0,1000)) |
||
256 | |||
584 | FredericG | 257 | # end of class App |
258 | |||
259 | if __name__ == "__main__": |
||
260 | VibrationTestGui = App(0) |
||
261 | VibrationTestGui.MainLoop() |