Getting mouse position interms of canvas unit.

perl lover hemanexp at yahoo.com
Mon Apr 28 11:23:18 EDT 2003


hi,
  iam new to python and tkinter. I have created a
canvas of size 300m * 300m (in millimeter). I bind
mouse move method to canvas. when i move the mouse
over the canvas the mouse position gets printed in
pixel unit. But i want to get mouse position values
interms of canvas unit (ie, millimeter). How can i get
mouse position values interms of canvas unit?

   My program is given below.
   *****************************

from Tkinter import *
root = Tk()
c = Canvas(root,width="300m",height="300m",background
= 'gray')
c.pack()

def mouseMove(event):
        print c.canvasx(event.x), c.canvasy(event.y)

c.create_rectangle('16m','10.5m','21m','15.5m',fill='blue')
c.bind('<Motion>',mouseMove)
root.mainloop()

Tnanx



__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com





More information about the Python-list mailing list