鼠标事件演示程序:
鼠标移动即显示鼠标坐标
JoinoseDemo_EVT_MOTION
1 #!/usr/bin/python
2 # -*- coding: UTF-8 -*-
3 # $Id: JoinoseDemo_EVT_MOTION.py 40 2006-05-18 04:31:45Z Administrator $
4 import wx
5
6 class MainApp(wx.App):
7 def __init__(self):
8 wx.App.__init__(self,True,'JoinoseDemo_EVT_MOTION.log')
9 self.Bind(wx.EVT_MOTION, self.OnMouse)
10
11 def OnMouse(self,event):
12 ms = wx.GetMouseState()
13 self.lblX.SetLabel( "X:"+str(ms.x) )
14 self.lblY.SetLabel( "Y:"+str(ms.y) )
15 def OnInit(self):
16 frame=wx.Frame(None,-1,"EVT_MOTION事件演示")
17 panel=wx.Panel(frame)
18 self.lblX=wx.StaticText(panel,label="X:",pos=(100,100))
19 self.lblY=wx.StaticText(panel,label="Y:",pos=(100,200))
20
21 frame.Show()
22 return True
23
24 if __name__=='__main__':
25 app=MainApp()
26 app.MainLoop()