Advertisement
here2share

# Tk_MouseMove.py

Feb 3rd, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. # Tk_MouseMove.py
  2.  
  3. import Tkinter as tk
  4.  
  5. def mv(event):
  6.     x = event.x
  7.     y = event.y
  8.     c.coords('current', x - 10, y - 10, x + 10, y + 10)
  9.     tag=c.gettags('current')
  10.     print tag[0],[x,y]
  11.  
  12. c = tk.Canvas(width=300, height=200)
  13. c.pack()
  14. x=10; y=30
  15. for i in range(9):
  16.   t='ball_'+str(i+1)
  17.   c.create_oval(x, x, y, y,
  18.     fill='red', tag=t)
  19.   x=x+20; y=x+20
  20.   c.tag_bind(t,'<B1-Motion>',mv)
  21.  
  22. c.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement