]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/Joystick.py
Added some info panels that show size and colour attributes about the widget
[wxWidgets.git] / wxPython / demo / Joystick.py
index f3bdcd7b338caa2a50a8e982a74dfdb727e59c27..06ec0636012078425814715d4ac6afc1d94926ab 100644 (file)
@@ -5,7 +5,7 @@
 # Author:      Jeff Grimmett (grimmtoo@softhome.net), adapted from original
 #              .wdr-derived demo
 #
-# Created:     01/02/04
+# Created:     02-Jan-2004
 # RCS-ID:      $Id$
 # Copyright:
 # Licence:     wxWindows license
 import  math
 import  wx
 
+haveJoystick = True
+if wx.Platform == "__WXMAC__":
+    haveJoystick = False
+
 #----------------------------------------------------------------------------
 
 # Once all supported versions of Python support 32-bit integers on all
@@ -91,18 +95,18 @@ class JoyGauge(wx.Panel):
 
         # Restrict our drawing activities to the square defined
         # above.
-        dc.SetClippingRegion((xorigin, yorigin), (edgeSize, edgeSize))
+        dc.SetClippingRegion(xorigin, yorigin, edgeSize, edgeSize)
 
         # Optimize drawing a bit (for Win)
         dc.BeginDrawing()
 
         dc.SetBrush(wx.Brush(wx.Colour(251, 252, 237)))
-        dc.DrawRectangle((xorigin, yorigin), (edgeSize, edgeSize))
+        dc.DrawRectangle(xorigin, yorigin, edgeSize, edgeSize)
 
         dc.SetPen(wx.Pen(wx.BLACK, 1, wx.DOT_DASH))
 
-        dc.DrawLine((xorigin, yorigin + center), (xorigin + edgeSize, yorigin + center))
-        dc.DrawLine((xorigin + center, yorigin), (xorigin + center, yorigin + edgeSize))
+        dc.DrawLine(xorigin, yorigin + center, xorigin + edgeSize, yorigin + center)
+        dc.DrawLine(xorigin + center, yorigin, xorigin + center, yorigin + edgeSize)
 
         if self.stick:
             # Get the joystick position as a float
@@ -235,14 +239,14 @@ class POVGauge(wx.Panel):
 
         # our 'raster'.
         dc.SetBrush(wx.Brush(wx.WHITE))
-        dc.DrawCircle((xcenter, ycenter), diameter/2)
+        dc.DrawCircle(xcenter, ycenter, diameter/2)
         dc.SetBrush(wx.Brush(wx.BLACK))
-        dc.DrawCircle((xcenter, ycenter), 10)
+        dc.DrawCircle(xcenter, ycenter, 10)
 
         # fancy decorations
         dc.SetPen(wx.Pen(wx.BLACK, 1, wx.DOT_DASH))
-        dc.DrawLine((xorigin, ycenter), (xorigin + diameter, ycenter))
-        dc.DrawLine((xcenter, yorigin), (xcenter, yorigin + diameter))
+        dc.DrawLine(xorigin, ycenter, xorigin + diameter, ycenter)
+        dc.DrawLine(xcenter, yorigin, xcenter, yorigin + diameter)
 
         if self.stick:
             if self.avail:
@@ -280,11 +284,11 @@ class POVGauge(wx.Panel):
 
                 # Draw the line
                 dc.SetPen(wx.Pen(wx.BLUE, 2))
-                dc.DrawLine((xcenter, ycenter), (nx, ny))
+                dc.DrawLine(xcenter, ycenter, nx, ny)
 
                 # And a little thing to show the endpoint
                 dc.SetBrush(wx.Brush(wx.BLUE))
-                dc.DrawCircle((nx, ny), 8)
+                dc.DrawCircle(nx, ny, 8)
 
         # Turn off drawing optimization
         dc.EndDrawing()
@@ -458,7 +462,7 @@ class LED(wx.Panel):
         else:
             dc.SetBrush(wx.Brush(wx.BLACK))
 
-        dc.DrawCircle((center, center), bw/2)
+        dc.DrawCircle(center, center, bw/2)
 
         txt = str(self.number)
 
@@ -479,7 +483,7 @@ class LED(wx.Panel):
         # functions. The pseudo-shadow gives the text contrast
         # regardless of whether the bar is under it or not.
         dc.SetTextForeground(wx.WHITE)
-        dc.DrawText(txt, (tx, ty))
+        dc.DrawText(txt, tx, ty)
 
         # Turn off drawing optimization
         dc.EndDrawing()
@@ -705,10 +709,10 @@ class AxisBar(wx.Gauge):
         # functions. The pseudo-shadow gives the text contrast
         # regardless of whether the bar is under it or not.
         dc.SetTextForeground(wx.BLACK)
-        dc.DrawText(txt, (tx, ty))
+        dc.DrawText(txt, tx, ty)
 
         dc.SetTextForeground('white')
-        dc.DrawText(txt, (tx-1, ty-1))
+        dc.DrawText(txt, tx-1, ty-1)
 
 
 #----------------------------------------------------------------------------
@@ -963,8 +967,17 @@ class JoystickDemoPanel(wx.Panel):
 #----------------------------------------------------------------------------
 
 def runTest(frame, nb, log):
-    win = JoystickDemoPanel(nb, log)
-    return win
+    if haveJoystick:
+        win = JoystickDemoPanel(nb, log)
+        return win
+    else:
+        dlg = wx.MessageDialog(
+                frame, 'wx.Joystick is not available on this platform.',
+                'Sorry', wx.OK | wx.ICON_INFORMATION
+                )
+        dlg.ShowModal()
+        dlg.Destroy()
+    
 
 #----------------------------------------------------------------------------
 
@@ -1070,4 +1083,4 @@ needed, then re-start the timer, possibly using wx.CallAfter().
 if __name__ == '__main__':
     import sys,os
     import run
-    run.main(['', os.path.basename(sys.argv[0])])
+    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])