]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/GetMouseState.py
4 #----------------------------------------------------------------------
6 class TestPanel(wx
.Panel
):
7 def __init__(self
, parent
, log
):
9 wx
.Panel
.__init
__(self
, parent
, -1)
11 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
14 sizer
.Add(wx
.StaticText(
16 "Mouse and modifier state can be polled with wx.GetMouseState"),
17 0, wx
.CENTER|wx
.ALL
, 10)
18 sizer
.Add(wx
.StaticLine(self
), 0, wx
.EXPAND|wx
.TOP
, 10)
20 row
= wx
.BoxSizer(wx
.HORIZONTAL
)
21 sizer
.Add(row
, 0, wx
.CENTER
)
23 fgs
= wx
.FlexGridSizer(cols
=2, hgap
=5, vgap
=10)
24 row
.Add(fgs
, 0, wx
.ALL
, 30)
26 lbl
= wx
.StaticText(self
, -1, "X pos:")
27 self
.x
= wx
.StaticText(self
, -1, "00000")
31 lbl
= wx
.StaticText(self
, -1, "Y pos:")
32 self
.y
= wx
.StaticText(self
, -1, "00000")
37 lbl
= wx
.StaticText(self
, -1, "Left down:")
38 self
.lft
= wx
.StaticText(self
, -1, "False")
42 lbl
= wx
.StaticText(self
, -1, "Middle Down:")
43 self
.mid
= wx
.StaticText(self
, -1, "False")
47 lbl
= wx
.StaticText(self
, -1, "Right down:")
48 self
.rgt
= wx
.StaticText(self
, -1, "False")
52 fgs
= wx
.FlexGridSizer(cols
=2, hgap
=5, vgap
=10)
53 row
.Add(fgs
, 0, wx
.ALL
, 30)
55 lbl
= wx
.StaticText(self
, -1, "Control down:")
56 self
.ctrl
= wx
.StaticText(self
, -1, "False")
60 lbl
= wx
.StaticText(self
, -1, "Shift down:")
61 self
.shft
= wx
.StaticText(self
, -1, "False")
65 lbl
= wx
.StaticText(self
, -1, "Alt down:")
66 self
.alt
= wx
.StaticText(self
, -1, "False")
70 lbl
= wx
.StaticText(self
, -1, "Meta down:")
71 self
.meta
= wx
.StaticText(self
, -1, "False")
75 lbl
= wx
.StaticText(self
, -1, "Cmd down:")
76 self
.cmd
= wx
.StaticText(self
, -1, "False")
80 self
.timer
= wx
.Timer(self
)
81 self
.Bind(wx
.EVT_TIMER
, self
.OnTimer
, self
.timer
)
85 def OnTimer(self
, evt
):
86 ms
= wx
.GetMouseState()
87 self
.x
.SetLabel( str(ms
.x
) )
88 self
.y
.SetLabel( str(ms
.y
) )
90 self
.lft
.SetLabel( str(ms
.leftDown
) )
91 self
.mid
.SetLabel( str(ms
.middleDown
) )
92 self
.rgt
.SetLabel( str(ms
.rightDown
) )
94 self
.ctrl
.SetLabel( str(ms
.controlDown
) )
95 self
.shft
.SetLabel( str(ms
.shiftDown
) )
96 self
.alt
.SetLabel( str(ms
.altDown
) )
97 self
.meta
.SetLabel( str(ms
.metaDown
) )
98 self
.cmd
.SetLabel( str(ms
.cmdDown
) )
101 #----------------------------------------------------------------------
103 def runTest(frame
, nb
, log
):
104 win
= TestPanel(nb
, log
)
107 #----------------------------------------------------------------------
111 overview
= """<html><body>
112 <h2><center>wx.GetMouseState</center></h2>
114 The mouse and modifier state can be polled with the wx.GetMouseState
115 function. It returns an instance of a wx.MouseState object that
116 contains the current position of the mouse pointer in screen
117 coordinants, as well as boolean values indicating the up/down status
118 of the mouse buttons and the modifier keys.
126 if __name__
== '__main__':
129 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])