Posted By

whitetiger on 11/09/06


Tagged

event default python key count mouse delicious series60 screenshot pys60 capture wxpython callback s60 keyboard press dictionary


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

yuconner
anayhk


Python - Mouse Capture


 / Published in: Python
 

  1. import wx
  2.  
  3. class MyFrame(wx.Frame):
  4.  
  5. def __init__(self):
  6.  
  7. # creo un frame
  8. wx.Frame.__init__(self, None, -1, 'My Frame', size=(300, 300))
  9. # aggiungo un pannello
  10. panel = wx.Panel(self, -1)
  11. # aggiungo un evento al pannello
  12. panel.Bind(wx.EVT_MOTION, self.OnMove)
  13. # aggiungo un controllo di testo
  14. self.posCtrl = wx.TextCtrl(panel, -1, 'Pos: ', pos=(40, 10))
  15.  
  16. def OnMove(self, event):
  17.  
  18. # catturo la posizione del mouse
  19. pos = event.GetPosition()
  20. # scrivo tale posizione nel controllo di testo
  21. self.posCtrl.SetValue('%s, %s' % (pos.x, pos.y))
  22.  
  23. if '__main__' == __name__:
  24.  
  25. app = wx.PySimpleApp()
  26. frame = MyFrame()
  27. frame.Show()
  28. app.MainLoop()

Report this snippet  

You need to login to post a comment.