Subversion Repositories Projects

Rev

Rev 585 | Rev 587 | 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
 
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
 
585 FredericG 33
class wxFrame(wx.Panel):
34
    def __init__(self, *args, **kwds):
586 FredericG 35
        # content of this block not found: did you rename this class?
36
        pass
585 FredericG 37
 
38
    def __set_properties(self):
586 FredericG 39
        # content of this block not found: did you rename this class?
585 FredericG 40
        pass
41
 
42
    def __do_layout(self):
586 FredericG 43
        # content of this block not found: did you rename this class?
585 FredericG 44
        pass
45
 
46
# end of class wxFrame
47
 
48
 
49
class MyFrame(wx.Frame):
50
    def __init__(self, *args, **kwds):
51
        # content of this block not found: did you rename this class?
52
        pass
53
 
54
    def __set_properties(self):
55
        # content of this block not found: did you rename this class?
56
        pass
57
 
58
    def __do_layout(self):
59
        # content of this block not found: did you rename this class?
60
        pass
61
 
62
# end of class MyFrame
63
 
64
 
584 FredericG 65
class MainFrame(wx.Frame):
66
    def __init__(self, *args, **kwds):
67
        # begin wxGlade: MainFrame.__init__
68
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
69
        wx.Frame.__init__(self, *args, **kwds)
70
        self.Port = wx.StaticText(self, -1, "Port")
71
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
72
        self.label_5 = wx.StaticText(self, -1, "label_5")
73
        self.text_ctrl_5 = wx.TextCtrl(self, -1, "")
74
        self.label_2 = wx.StaticText(self, -1, "Motor(s)")
75
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
76
        self.label_6 = wx.StaticText(self, -1, "label_6")
77
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "")
78
        self.label_3 = wx.StaticText(self, -1, "Channel(s)")
79
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
80
        self.label_7 = wx.StaticText(self, -1, "label_7")
81
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "")
82
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
83
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
84
        self.label_8 = wx.StaticText(self, -1, "label_8")
85
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
86
        self.button_1 = wx.Button(self, -1, "button_1")
585 FredericG 87
        self.GraphFanel = wx.Panel(self, -1)
586 FredericG 88
        self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
584 FredericG 89
 
90
        self.__set_properties()
91
        self.__do_layout()
92
        # end wxGlade
93
 
585 FredericG 94
 
95
 
584 FredericG 96
    def __set_properties(self):
97
        # begin wxGlade: MainFrame.__set_properties
98
        self.SetTitle("frame_1")
585 FredericG 99
        self.GraphFanel.SetMinSize((800,300))
584 FredericG 100
        # end wxGlade
101
 
102
    def __do_layout(self):
103
        # begin wxGlade: MainFrame.__do_layout
104
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
586 FredericG 105
        grid_sizer_2 = wx.GridSizer(2, 1, 4, 4)
584 FredericG 106
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
107
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
108
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
109
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
110
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
111
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
112
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
113
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
114
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
115
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
116
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
117
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
118
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
119
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
120
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
121
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
122
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
123
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
124
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
585 FredericG 125
        sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0)
586 FredericG 126
        grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0)
127
        sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
584 FredericG 128
        self.SetSizer(sizer_1)
129
        sizer_1.Fit(self)
130
        self.Layout()
131
        # end wxGlade
132
 
586 FredericG 133
        # Configure Graph
585 FredericG 134
        self.client = wx.lib.plot.PlotCanvas(self.GraphFanel)
135
        self.client.SetPointLabelFunc(self.DrawPointLabel)
136
 
137
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
138
        self.client.SetFontSizeAxis(10)
139
        self.client.SetFontSizeLegend(7)
140
        self.client.setLogScale((False,False))
141
        self.client.SetXSpec('auto')
142
        self.client.SetYSpec('auto')
143
 
144
        data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
145
        data1.shape = (100, 2)
146
        data1[:,1] = _Numeric.sin(data1[:,0])
147
        markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1)
148
        pi = 3.1415
149
        markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
150
                          (3.*pi/4., -1)], legend='Cross Legend', colour='blue',
151
                          marker='cross')
152
        self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
586 FredericG 153
 
154
        # Configure TestListCtrl
155
        self.TestListCtrl.InsertColumn(0, "Name")
156
        self.TestListCtrl.InsertColumn(1, "Result")
157
 
585 FredericG 158
    def DrawPointLabel(self, dc, mDataDict):
159
        """This is the fuction that defines how the pointLabels are plotted
160
            dc - DC that will be passed
161
            mDataDict - Dictionary of data that you want to use for the pointLabel
162
 
163
            As an example I have decided I want a box at the curve point
164
            with some text information about the curve plotted below.
165
            Any wxDC method can be used.
166
        """
167
        # ----------
168
        dc.SetPen(wx.Pen(wx.BLACK))
169
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
170
 
171
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
172
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
173
        px,py = mDataDict["pointXY"]
174
        cNum = mDataDict["curveNum"]
175
        pntIn = mDataDict["pIndex"]
176
        legend = mDataDict["legend"]
177
        #make a string to display
178
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
179
        dc.DrawText(s, sx , sy+1)
180
        # -----------
181
 
584 FredericG 182
# end of class MainFrame
183
 
184
 
586 FredericG 185
class VibTest:
186
    def __init__(self, name, rawData):
187
        self.name = name
188
        self.rawData = rawData
189
 
584 FredericG 190
class App(wx.App):
586 FredericG 191
    def __init__(self, par):
192
        print "A"
193
        self.VibTests = []
194
 
195
        wx.App.__init__(self, par)
196
 
197
 
198
    def AddTest(self, name, rawData):
199
        test = VibTest(name, rawData)
200
        self.VibTests.append(test)
201
 
202
        index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name)
203
        self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK")
204
 
584 FredericG 205
    def OnInit(self):
206
        wx.InitAllImageHandlers()
586 FredericG 207
        self.frame_1 = MainFrame(None, -1, "")
208
        self.SetTopWindow(self.frame_1)
209
 
210
        print "B"
211
 
212
        self.AddTest("Test1", range(0,1000))
213
        self.AddTest("Test2", range(0,1000))
214
 
215
        self.frame_1.Show()
584 FredericG 216
        return 1
217
 
218
# end of class App
219
 
220
if __name__ == "__main__":
221
    VibrationTestGui = App(0)
222
    VibrationTestGui.MainLoop()