Reading coords from a scrolled Tkinter Canvas widget?

G. Willoughby never at
Sun Jun 2 17:44:17 CEST 2002

I am having a few problems reading the correct coords from a scrolled canvas
widget! e.g. i have a .jpg about 2000x2000pixels displayed inside a canvas
widget measuring 564x564pixels when i scroll the canvas using the attached
scrollbars i want to click the mouse and read the x/y coords of the .jpg
where my cursor is, not the canvas widget, any ideas? This is the code i
have at the minute:

self.thumbnail=Canvas(self.frame1, bd=1, relief=SUNKEN, width=564,
height=564, scrollregion=(0, 0, 564, 564))
self.thumbnail.scrollX=Scrollbar(self.frame1, orient=HORIZONTAL)
self.thumbnail.scrollY=Scrollbar(self.frame1, orient=VERTICAL)
self.thumbnail.scrollX.pack(side=BOTTOM, fill=X)
self.thumbnail.scrollY.pack(side=RIGHT, fill=Y)

self.thumbnail.bind("<Button-1>", self.getCoords)

def getCoords(self):

This code was working perfectly with images sized 564pixels but i've only
just noticed this will not work with bigger images  :(

--G. Willoughby

More information about the Python-list mailing list