]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxJoystick.py
Swtch to using Bind, and use better styles for the code viewer
[wxWidgets.git] / wxPython / demo / wxJoystick.py
CommitLineData
ac346f50
RD
1
2#----------------------------------------------------------------------------
3
4from wxPython.wx import *
5from joystick_wdr import *
6
7
8class JoystickTestPanel(wxPanel):
9 def __init__(self, parent, id,
d14a1e28 10 pos = wxDefaultPosition, size = wxDefaultSize,
ac346f50
RD
11 style = wxTAB_TRAVERSAL ):
12 wxPanel.__init__(self, parent, id, pos, size, style)
13
1e4a197e 14 MakeJoystickTestPanel( self, True )
ac346f50 15
25d73e0f
RD
16 try:
17 self.stick = wxJoystick()
18 self.stick.SetCapture(self)
19 EVT_JOYSTICK_EVENTS(self, self.OnJoystick)
20 self.UpdateFields()
21 except NotImplementedError, v:
22 wxMessageBox(str(v), "Exception Message")
ac346f50
RD
23
24
25 def UpdateFields(self):
26 s = self.stick
27 self.GetXPositionCtrl().SetValue(str(s.GetPosition().x))
28 self.GetYPositionCtrl().SetValue(str(s.GetPosition().y))
29 self.GetZPositionCtrl().SetValue(str(s.GetZPosition()))
30 self.GetPovCtsPosCtrl().SetValue(str(s.GetPOVPosition()))
31 self.GetRudderPosCtrl().SetValue(str(s.GetRudderPosition()))
32 self.GetHasRudderCtrl().SetValue(str(s.HasRudder()))
33 self.GetHasZCtrl().SetValue(str(s.HasZ()))
34 self.GetHasPovCtrl().SetValue(str(s.HasPOV()))
35 self.GetHasPov4dirCtrl().SetValue(str(s.HasPOV4Dir()))
36 self.GetMfgIdCtrl().SetValue(str(s.GetManufacturerId()))
37 self.GetProdNameCtrl().SetValue(str(s.GetProductName()))
38 self.GetZMinCtrl().SetValue(str(s.GetZMin()))
39 self.GetXMaxCtrl().SetValue(str(s.GetXMax()))
40 self.GetNumButtonsCtrl().SetValue(str(s.GetNumberButtons()))
41 self.GetNumAxesCtrl().SetValue(str(s.GetNumberAxes()))
42 self.GetPollingMinCtrl().SetValue(str(s.GetPollingMin()))
43 self.GetPollingMaxCtrl().SetValue(str(s.GetPollingMax()))
44 self.GetUMinCtrl().SetValue(str(s.GetUMin()))
45 self.GetUMaxCtrl().SetValue(str(s.GetUMax()))
46 self.GetButtonStateCtrl().SetValue(str(s.GetButtonState()))
47 self.GetPovPositionCtrl().SetValue(str(s.GetPOVPosition()))
48 self.GetUPositionCtrl().SetValue(str(s.GetUPosition()))
49 self.GetVPositionCtrl().SetValue(str(s.GetVPosition()))
50 self.GetHasUCtrl().SetValue(str(s.HasU()))
51 self.GetHasVCtrl().SetValue(str(s.HasV()))
52 self.GetHasPovCtsCtrl().SetValue(str(s.HasPOVCTS()))
53 self.GetNumSticksCtrl().SetValue(str(s.GetNumberJoysticks()))
54 self.GetXMinCtrl().SetValue(str(s.GetXMin()))
55 self.GetYMinCtrl().SetValue(str(s.GetYMin()))
56 self.GetYMaxCtrl().SetValue(str(s.GetYMax()))
57 self.GetZMaxCtrl().SetValue(str(s.GetZMax()))
58 self.GetMaxButtonsCtrl().SetValue(str(s.GetMaxButtons()))
59 self.GetMaxAxesCtrl().SetValue(str(s.GetMaxAxes()))
60 self.GetRudderMinCtrl().SetValue(str(s.GetRudderMin()))
61 self.GetRudderMaxCtrl().SetValue(str(s.GetRudderMax()))
62 self.GetVMinCtrl().SetValue(str(s.GetVMin()))
63 self.GetVMaxCtrl().SetValue(str(s.GetVMax()))
64
65
66 def OnJoystick(self, evt):
67 self.UpdateFields()
68
69
70 # WDR: methods for JoystickTestPanel
71
72 def GetYPositionCtrl(self):
25832b3f 73 return self.FindWindowById(ID_Y_Position_Ctrl)
ac346f50
RD
74
75 def GetXPositionCtrl(self):
25832b3f 76 return self.FindWindowById(ID_X_Position_Ctrl)
ac346f50
RD
77
78
79 def GetVMaxCtrl(self):
25832b3f 80 return self.FindWindowById(ID_V_Max_Ctrl)
ac346f50
RD
81
82 def GetVMinCtrl(self):
25832b3f 83 return self.FindWindowById(ID_V_Min_Ctrl)
ac346f50
RD
84
85 def GetRudderMaxCtrl(self):
25832b3f 86 return self.FindWindowById(ID_Rudder_Max_Ctrl)
ac346f50
RD
87
88 def GetRudderMinCtrl(self):
25832b3f 89 return self.FindWindowById(ID_Rudder_Min_Ctrl)
ac346f50
RD
90
91 def GetMaxAxesCtrl(self):
25832b3f 92 return self.FindWindowById(ID_Max_Axes_Ctrl)
ac346f50
RD
93
94 def GetMaxButtonsCtrl(self):
25832b3f 95 return self.FindWindowById(ID_Max_Buttons_Ctrl)
ac346f50
RD
96
97 def GetZMaxCtrl(self):
25832b3f 98 return self.FindWindowById(ID_Z_Max_Ctrl)
ac346f50
RD
99
100 def GetYMaxCtrl(self):
25832b3f 101 return self.FindWindowById(ID_Y_Max_Ctrl)
ac346f50
RD
102
103 def GetYMinCtrl(self):
25832b3f 104 return self.FindWindowById(ID_Y_Min_Ctrl)
ac346f50
RD
105
106 def GetXMinCtrl(self):
25832b3f 107 return self.FindWindowById(ID_X_Min_Ctrl)
ac346f50
RD
108
109 def GetNumSticksCtrl(self):
25832b3f 110 return self.FindWindowById(ID_Num_Sticks_Ctrl)
ac346f50
RD
111
112 def GetHasPovCtsCtrl(self):
25832b3f 113 return self.FindWindowById(ID_Has_POV_CTS_Ctrl)
ac346f50
RD
114
115 def GetHasVCtrl(self):
25832b3f 116 return self.FindWindowById(ID_Has_V_Ctrl)
ac346f50
RD
117
118 def GetHasUCtrl(self):
25832b3f 119 return self.FindWindowById(ID_Has_U_Ctrl)
ac346f50
RD
120
121 def GetVPositionCtrl(self):
25832b3f 122 return self.FindWindowById(ID_V_Position_Ctrl)
ac346f50
RD
123
124 def GetUPositionCtrl(self):
25832b3f 125 return self.FindWindowById(ID_U_Position_Ctrl)
ac346f50
RD
126
127 def GetPovPositionCtrl(self):
25832b3f 128 return self.FindWindowById(ID_POV_Position_Ctrl)
ac346f50
RD
129
130 def GetButtonStateCtrl(self):
25832b3f 131 return self.FindWindowById(ID_Button_State_Ctrl)
ac346f50
RD
132
133 def GetUMaxCtrl(self):
25832b3f 134 return self.FindWindowById(ID_U_Max_Ctrl)
ac346f50
RD
135
136 def GetUMinCtrl(self):
25832b3f 137 return self.FindWindowById(ID_U_Min_Ctrl)
ac346f50
RD
138
139 def GetPollingMaxCtrl(self):
25832b3f 140 return self.FindWindowById(ID_Polling_Max_Ctrl)
ac346f50
RD
141
142 def GetPollingMinCtrl(self):
25832b3f 143 return self.FindWindowById(ID_Polling_Min_Ctrl)
ac346f50
RD
144
145 def GetNumAxesCtrl(self):
25832b3f 146 return self.FindWindowById(ID_Num_Axes_Ctrl)
ac346f50
RD
147
148 def GetNumButtonsCtrl(self):
25832b3f 149 return self.FindWindowById(ID_Num_Buttons_Ctrl)
ac346f50
RD
150
151 def GetXMaxCtrl(self):
25832b3f 152 return self.FindWindowById(ID_X_Max_Ctrl)
ac346f50
RD
153
154 def GetZMinCtrl(self):
25832b3f 155 return self.FindWindowById(ID_Z_Min_Ctrl)
ac346f50
RD
156
157 def GetProdNameCtrl(self):
25832b3f 158 return self.FindWindowById(ID_Prod_Name_Ctrl)
ac346f50
RD
159
160 def GetMfgIdCtrl(self):
25832b3f 161 return self.FindWindowById(ID_Mfg_ID_Ctrl)
ac346f50
RD
162
163 def GetHasPov4dirCtrl(self):
25832b3f 164 return self.FindWindowById(ID_Has_POV_4DIR_Ctrl)
ac346f50
RD
165
166 def GetHasPovCtrl(self):
25832b3f 167 return self.FindWindowById(ID_Has_POV_Ctrl)
ac346f50
RD
168
169 def GetHasZCtrl(self):
25832b3f 170 return self.FindWindowById(ID_Has_Z_Ctrl)
ac346f50
RD
171
172 def GetHasRudderCtrl(self):
25832b3f 173 return self.FindWindowById(ID_Has_Rudder_Ctrl)
ac346f50
RD
174
175 def GetRudderPosCtrl(self):
25832b3f 176 return self.FindWindowById(ID_Rudder_Pos_Ctrl)
ac346f50
RD
177
178 def GetPovCtsPosCtrl(self):
25832b3f 179 return self.FindWindowById(ID_POV_CTS_Pos_Ctrl)
ac346f50
RD
180
181 def GetZPositionCtrl(self):
25832b3f 182 return self.FindWindowById(ID_Z_Position_Ctrl)
ac346f50
RD
183
184 # WDR: handler implementations for JoysticktestPanel
185
186
187#----------------------------------------------------------------------
188
189def runTest(frame, nb, log):
190 win = JoystickTestPanel(nb, -1)
191 return win
192
193#----------------------------------------------------------------------
194
195
196overview = """\
197"""
1fded56b
RD
198
199
200
201
202if __name__ == '__main__':
203 import sys,os
204 import run
205 run.main(['', os.path.basename(sys.argv[0])])
206