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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -