-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathTestEvents.py
executable file
·61 lines (40 loc) · 1.4 KB
/
TestEvents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
"""
A very simple app for testing DC and mouse event functionality
"""
import wx
class TestPanel(wx.Panel):
def __init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_PAINT , self.OnPaint)
self.Bind(wx.EVT_LEFT_DOWN , self.LeftDown)
self.Bind(wx.EVT_LEFT_UP , self.LeftUp)
self.Bind(wx.EVT_MOTION, self.Move)
# This would capture all events in the same handler
## self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvents)
def OnPaint(self, event):
dc = wx.PaintDC(self)
dc.BeginDrawing()
dc.Clear()
dc.DrawText("Text", 50, 50 )
dc.EndDrawing()
def OnMouseEvents(self,event):
if event.IsButton():
print(event.GetButton())
def LeftDown(self, event):
print("In LeftDown, at:", event.Position)
def LeftUp(self, event):
print("In LeftUp at:", event.Position)
def Move(self, event):
print("In Motion event at:", event.Position)
class DemoApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, title="Mouse Event Test", size=(200,200),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
print(type(frame))
panel = TestPanel(frame)
frame.Show(True)
return True
if __name__ == "__main__":
app = DemoApp(False)
app.MainLoop()