Greetings,
Just started a new small project for which some low level mouse event tracking seems handy. So I started with reading about events and event handlers. My first tryout is translating mouse event numbers (obtained by evt,GeteventType() back to some meaningfull text. No luck so far. Could someone please have a look at this code and tell me what I am missing?
#
# mousevents.py
#
import wx
class Example(wx.Frame):
def __init__(self, *args, **kw):
super(Example, self).__init__(*args, **kw)
self.SetSize(0,0,1024,768)
self.Centre()
self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvent)
def OnMouseEvent (self, evt):
et = evt.GetEventType()
if et == wx.EVT_ENTER_WINDOW:
print ("EVT_ENTER_WINDOW")
elif et == wx.EVT_LEAVE_WINDOW:
print ("EVT_LEAVE_WINDOW")
elif et == wx.EVT_LEFT_DOWN:
print ("EVT_LEFT_DOWN")
elif et == wx.EVT_LEFT_UP:
print ("EVT_LEFT_UP")
elif et == wx.EVT_LEFT_DCLICK:
print ("EVT_LEFT_DCLICK")
elif et == wx.EVT_MIDDLE_DOWN:
print ("EVT_MIDDLE_DOWN")
elif et == wx.EVT_MIDDLE_UP:
print ("EVT_MIDDLE_UP")
elif et == wx.EVT_MIDDLE_DCLICK:
print ("EVT_MIDDLE_DCLICK")
elif et == wx.EVT_RIGHT_DOWN:
print ("EVT_RIGHT_DOWN")
elif et == wx.EVT_RIGHT_UP:
print ("EVT_RIGHT_UP")
elif et == wx.EVT_RIGHT_DCLICK:
print ("EVT_RIGHT_DCLICK")
elif et == wx.EVT_MOUSE_AUX1_DOWN:
print ("EVT_MOUSE_AUX1_DOWN")
elif et == wx.EVT_MOUSE_AUX1_UP:
print ("EVT_MOUSE_AUX1_UP")
elif et == wx.EVT_MOUSE_AUX1_DCLICK:
print ("EVT_MOUSE_AUX1_DCLICK")
elif et == wx.EVT_MOUSE_AUX2_DOWN:
print ("EVT_MOUSE_AUX2_DOWN")
elif et == wx.EVT_MOUSE_AUX2_UP:
print ("EVT_MOUSE_AUX2_UP")
elif et == wx.EVT_MOUSE_AUX2_DCLICK:
print ("EVT_MOUSE_AUX2_DCLICK")
elif et == wx.EVT_MOTION:
print ("EVT_MOTION")
elif et == wx.EVT_MOUSEWHEEL:
print ("EVT_MOUSEWHEEL")
elif et == wx.EVT_MOUSE_EVENTS:
print ("EVT_MOUSE_EVENTS")
else:
print (et)
if __name__ == '__main__':
app = wx.App()
frm = Example(None)
frm.Show()
app.MainLoop()