Subversion Repositories Projects

Rev

Rev 584 | Rev 586 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 584 Rev 585
1
#!/usr/bin/env python
1
#!/usr/bin/env python
2
# -*- coding: iso-8859-15 -*-
2
# -*- coding: iso-8859-15 -*-
3
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009
3
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009
4
 
4
 
5
import wx
5
import wx
-
 
6
import wx.lib
-
 
7
import wx.lib.plot
-
 
8
 
-
 
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
6
 
26
 
7
# begin wxGlade: extracode
27
# begin wxGlade: extracode
8
# end wxGlade
28
# end wxGlade
9
 
29
 
10
 
30
 
-
 
31
 
-
 
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
 
11
 
70
 
12
class MainFrame(wx.Frame):
71
class MainFrame(wx.Frame):
13
    def __init__(self, *args, **kwds):
72
    def __init__(self, *args, **kwds):
14
        # begin wxGlade: MainFrame.__init__
73
        # begin wxGlade: MainFrame.__init__
15
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
74
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
16
        wx.Frame.__init__(self, *args, **kwds)
75
        wx.Frame.__init__(self, *args, **kwds)
17
        self.Port = wx.StaticText(self, -1, "Port")
76
        self.Port = wx.StaticText(self, -1, "Port")
18
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
77
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
19
        self.label_5 = wx.StaticText(self, -1, "label_5")
78
        self.label_5 = wx.StaticText(self, -1, "label_5")
20
        self.text_ctrl_5 = wx.TextCtrl(self, -1, "")
79
        self.text_ctrl_5 = wx.TextCtrl(self, -1, "")
21
        self.label_2 = wx.StaticText(self, -1, "Motor(s)")
80
        self.label_2 = wx.StaticText(self, -1, "Motor(s)")
22
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
81
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
23
        self.label_6 = wx.StaticText(self, -1, "label_6")
82
        self.label_6 = wx.StaticText(self, -1, "label_6")
24
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "")
83
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "")
25
        self.label_3 = wx.StaticText(self, -1, "Channel(s)")
84
        self.label_3 = wx.StaticText(self, -1, "Channel(s)")
26
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
85
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
27
        self.label_7 = wx.StaticText(self, -1, "label_7")
86
        self.label_7 = wx.StaticText(self, -1, "label_7")
28
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "")
87
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "")
29
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
88
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
30
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
89
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
31
        self.label_8 = wx.StaticText(self, -1, "label_8")
90
        self.label_8 = wx.StaticText(self, -1, "label_8")
32
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
91
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
33
        self.button_1 = wx.Button(self, -1, "button_1")
92
        self.button_1 = wx.Button(self, -1, "button_1")
-
 
93
        self.GraphFanel = wx.Panel(self, -1)
-
 
94
        self.panel_1 = wxFrame(self, -1)
34
 
95
 
35
        self.__set_properties()
96
        self.__set_properties()
36
        self.__do_layout()
97
        self.__do_layout()
37
        # end wxGlade
98
        # end wxGlade
-
 
99
 
-
 
100
       
38
 
101
 
39
    def __set_properties(self):
102
    def __set_properties(self):
40
        # begin wxGlade: MainFrame.__set_properties
103
        # begin wxGlade: MainFrame.__set_properties
41
        self.SetTitle("frame_1")
104
        self.SetTitle("frame_1")
-
 
105
        self.GraphFanel.SetMinSize((800,300))
42
        # end wxGlade
106
        # end wxGlade
43
 
107
 
44
    def __do_layout(self):
108
    def __do_layout(self):
45
        # begin wxGlade: MainFrame.__do_layout
109
        # begin wxGlade: MainFrame.__do_layout
46
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
110
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
47
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
111
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
48
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
112
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
49
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
113
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
50
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
114
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
51
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
115
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
52
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
116
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
53
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
117
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
54
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
118
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
55
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
119
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
56
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
120
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
57
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
121
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
58
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
122
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
59
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
123
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
60
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
124
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
61
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
125
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
62
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
126
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
63
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
127
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
64
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
128
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
65
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
129
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
66
        sizer_1.Add((20, 20), 1, wx.EXPAND, 0)
130
        sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0)
-
 
131
        sizer_1.Add(self.panel_1, 1, wx.ALL|wx.EXPAND, 0)
67
        self.SetSizer(sizer_1)
132
        self.SetSizer(sizer_1)
68
        sizer_1.Fit(self)
133
        sizer_1.Fit(self)
69
        self.Layout()
134
        self.Layout()
70
        # end wxGlade
135
        # end wxGlade
-
 
136
 
-
 
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
        # -----------
71
 
182
 
72
# end of class MainFrame
183
# end of class MainFrame
73
 
184
 
74
 
185
 
75
class App(wx.App):
186
class App(wx.App):
76
    def OnInit(self):
187
    def OnInit(self):
77
        wx.InitAllImageHandlers()
188
        wx.InitAllImageHandlers()
78
        frame_1 = MainFrame(None, -1, "")
189
        frame_1 = MainFrame(None, -1, "")
79
        self.SetTopWindow(frame_1)
190
        self.SetTopWindow(frame_1)
80
        frame_1.Show()
191
        frame_1.Show()
81
        return 1
192
        return 1
82
 
193
 
83
# end of class App
194
# end of class App
84
 
195
 
85
if __name__ == "__main__":
196
if __name__ == "__main__":
86
    VibrationTestGui = App(0)
197
    VibrationTestGui = App(0)
87
    VibrationTestGui.MainLoop()
198
    VibrationTestGui.MainLoop()
88
 
199