]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxJoystick.py
2 #----------------------------------------------------------------------------
4 from wxPython
.wx
import *
5 from joystick_wdr
import *
8 class JoystickTestPanel(wxPanel
):
9 def __init__(self
, parent
, id,
10 pos
= wxPyDefaultPosition
, size
= wxPyDefaultSize
,
11 style
= wxTAB_TRAVERSAL
):
12 wxPanel
.__init
__(self
, parent
, id, pos
, size
, style
)
14 MakeJoystickTestPanel( self
, true
)
17 self
.stick
= wxJoystick()
18 self
.stick
.SetCapture(self
)
19 EVT_JOYSTICK_EVENTS(self
, self
.OnJoystick
)
21 except NotImplementedError, v
:
22 wxMessageBox(str(v
), "Exception Message")
25 def UpdateFields(self
):
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()))
66 def OnJoystick(self
, evt
):
70 # WDR: methods for JoystickTestPanel
72 def GetYPositionCtrl(self
):
73 return wxPyTypeCast( self
.FindWindowById(ID_Y_Position_Ctrl
), "wxTextCtrl" )
75 def GetXPositionCtrl(self
):
76 return wxPyTypeCast( self
.FindWindowById(ID_X_Position_Ctrl
), "wxTextCtrl" )
79 def GetVMaxCtrl(self
):
80 return wxPyTypeCast( self
.FindWindowById(ID_V_Max_Ctrl
), "wxTextCtrl" )
82 def GetVMinCtrl(self
):
83 return wxPyTypeCast( self
.FindWindowById(ID_V_Min_Ctrl
), "wxTextCtrl" )
85 def GetRudderMaxCtrl(self
):
86 return wxPyTypeCast( self
.FindWindowById(ID_Rudder_Max_Ctrl
), "wxTextCtrl" )
88 def GetRudderMinCtrl(self
):
89 return wxPyTypeCast( self
.FindWindowById(ID_Rudder_Min_Ctrl
), "wxTextCtrl" )
91 def GetMaxAxesCtrl(self
):
92 return wxPyTypeCast( self
.FindWindowById(ID_Max_Axes_Ctrl
), "wxTextCtrl" )
94 def GetMaxButtonsCtrl(self
):
95 return wxPyTypeCast( self
.FindWindowById(ID_Max_Buttons_Ctrl
), "wxTextCtrl" )
97 def GetZMaxCtrl(self
):
98 return wxPyTypeCast( self
.FindWindowById(ID_Z_Max_Ctrl
), "wxTextCtrl" )
100 def GetYMaxCtrl(self
):
101 return wxPyTypeCast( self
.FindWindowById(ID_Y_Max_Ctrl
), "wxTextCtrl" )
103 def GetYMinCtrl(self
):
104 return wxPyTypeCast( self
.FindWindowById(ID_Y_Min_Ctrl
), "wxTextCtrl" )
106 def GetXMinCtrl(self
):
107 return wxPyTypeCast( self
.FindWindowById(ID_X_Min_Ctrl
), "wxTextCtrl" )
109 def GetNumSticksCtrl(self
):
110 return wxPyTypeCast( self
.FindWindowById(ID_Num_Sticks_Ctrl
), "wxTextCtrl" )
112 def GetHasPovCtsCtrl(self
):
113 return wxPyTypeCast( self
.FindWindowById(ID_Has_POV_CTS_Ctrl
), "wxTextCtrl" )
115 def GetHasVCtrl(self
):
116 return wxPyTypeCast( self
.FindWindowById(ID_Has_V_Ctrl
), "wxTextCtrl" )
118 def GetHasUCtrl(self
):
119 return wxPyTypeCast( self
.FindWindowById(ID_Has_U_Ctrl
), "wxTextCtrl" )
121 def GetVPositionCtrl(self
):
122 return wxPyTypeCast( self
.FindWindowById(ID_V_Position_Ctrl
), "wxTextCtrl" )
124 def GetUPositionCtrl(self
):
125 return wxPyTypeCast( self
.FindWindowById(ID_U_Position_Ctrl
), "wxTextCtrl" )
127 def GetPovPositionCtrl(self
):
128 return wxPyTypeCast( self
.FindWindowById(ID_POV_Position_Ctrl
), "wxTextCtrl" )
130 def GetButtonStateCtrl(self
):
131 return wxPyTypeCast( self
.FindWindowById(ID_Button_State_Ctrl
), "wxTextCtrl" )
133 def GetUMaxCtrl(self
):
134 return wxPyTypeCast( self
.FindWindowById(ID_U_Max_Ctrl
), "wxTextCtrl" )
136 def GetUMinCtrl(self
):
137 return wxPyTypeCast( self
.FindWindowById(ID_U_Min_Ctrl
), "wxTextCtrl" )
139 def GetPollingMaxCtrl(self
):
140 return wxPyTypeCast( self
.FindWindowById(ID_Polling_Max_Ctrl
), "wxTextCtrl" )
142 def GetPollingMinCtrl(self
):
143 return wxPyTypeCast( self
.FindWindowById(ID_Polling_Min_Ctrl
), "wxTextCtrl" )
145 def GetNumAxesCtrl(self
):
146 return wxPyTypeCast( self
.FindWindowById(ID_Num_Axes_Ctrl
), "wxTextCtrl" )
148 def GetNumButtonsCtrl(self
):
149 return wxPyTypeCast( self
.FindWindowById(ID_Num_Buttons_Ctrl
), "wxTextCtrl" )
151 def GetXMaxCtrl(self
):
152 return wxPyTypeCast( self
.FindWindowById(ID_X_Max_Ctrl
), "wxTextCtrl" )
154 def GetZMinCtrl(self
):
155 return wxPyTypeCast( self
.FindWindowById(ID_Z_Min_Ctrl
), "wxTextCtrl" )
157 def GetProdNameCtrl(self
):
158 return wxPyTypeCast( self
.FindWindowById(ID_Prod_Name_Ctrl
), "wxTextCtrl" )
160 def GetMfgIdCtrl(self
):
161 return wxPyTypeCast( self
.FindWindowById(ID_Mfg_ID_Ctrl
), "wxTextCtrl" )
163 def GetHasPov4dirCtrl(self
):
164 return wxPyTypeCast( self
.FindWindowById(ID_Has_POV_4DIR_Ctrl
), "wxTextCtrl" )
166 def GetHasPovCtrl(self
):
167 return wxPyTypeCast( self
.FindWindowById(ID_Has_POV_Ctrl
), "wxTextCtrl" )
169 def GetHasZCtrl(self
):
170 return wxPyTypeCast( self
.FindWindowById(ID_Has_Z_Ctrl
), "wxTextCtrl" )
172 def GetHasRudderCtrl(self
):
173 return wxPyTypeCast( self
.FindWindowById(ID_Has_Rudder_Ctrl
), "wxTextCtrl" )
175 def GetRudderPosCtrl(self
):
176 return wxPyTypeCast( self
.FindWindowById(ID_Rudder_Pos_Ctrl
), "wxTextCtrl" )
178 def GetPovCtsPosCtrl(self
):
179 return wxPyTypeCast( self
.FindWindowById(ID_POV_CTS_Pos_Ctrl
), "wxTextCtrl" )
181 def GetZPositionCtrl(self
):
182 return wxPyTypeCast( self
.FindWindowById(ID_Z_Position_Ctrl
), "wxTextCtrl" )
184 # WDR: handler implementations for JoysticktestPanel
187 #----------------------------------------------------------------------
189 def runTest(frame
, nb
, log
):
190 win
= JoystickTestPanel(nb
, -1)
193 #----------------------------------------------------------------------