Skip to content

Instantly share code, notes, and snippets.

@driscollis
Created October 19, 2017 13:22
Show Gist options
  • Save driscollis/753c5f69c5e641378862d7db9237bec0 to your computer and use it in GitHub Desktop.
Save driscollis/753c5f69c5e641378862d7db9237bec0 to your computer and use it in GitHub Desktop.
Get mouse coordinates in wxPython
import wx
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, title='Mouse Position')
panel = wx.Panel(self)
panel.Bind(wx.EVT_MOTION, self.on_mouse_movement)
self.Show()
def on_mouse_movement(self, event):
print(event.GetPosition())
if __name__ == '__main__':
app = wx.App(False)
frame = MyFrame()
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment