[Tutor] Problem in scalling............
Wed Apr 30 09:22:38 2003
perl lover <email@example.com> writes:
> i have a problem in scalling a canvas widget in
> tkinter. I have created a canvas of size 1000 * 1000.
> When i move the mouse over canvas the x,y values of
> mouse pointer are showned in status bar. It is working
> fine with normal canvas(ie, before scalling). I got
> 762*477 as bottom right pixel value. When i scallled
> the canvas stil i got the same value (762*477) if the
> mouse is placed at bottom right of the canvas. Since i
> used 2 as scalling factor for both x,y, I expect
> bottom right value is as half as normal canvas (ie,
> 381,248). How can i get it? My program is given below.
I'm not an expert at Tkinter, but my impression is that what you get
is the desired behavior. If you want the real x,y coordinates, you
could either manually divide by the scaling factor, or use the
event.x,event.y values instead, possibly subtracting the coordinates
of the top left corner of the canvas widget.
Now that I read a little more careful, I'm not sure I understand what
your problem is, probably due to my lack of knowledge about the canvas
widget. I'll have to experiment a little with this.
> from Tkinter import *
> class App:
> def __init__(self,parent):
> self.myparent = parent
> self.canvas =
> def ZoomIn(self,event):
> def mm(self,event):
> root = Tk()
> myapp = App(root)
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> Tutor maillist - Tutor@python.org