Mouse Position Python Tkinter -
is there way position of mouse , set var?
you set callback react <motion> events:
import tkinter tk root = tk.tk() def motion(event): x, y = event.x, event.y print('{}, {}'.format(x, y)) root.bind('<motion>', motion) root.mainloop() i'm not sure kind of variable want. above, set local variables x , y mouse coordinates.
if make motion class method, set instance attributes self.x , self.y mouse coordinates, accessible other class methods.
Comments
Post a Comment