1

I'm working on a project where I have to zoom in an image, I have a program but when I zoom, the focus of the zoom depends on the canvas coordinates and not the current window coordinates so the zoom is not centered on the window.

def zoomer(self,event):
    if (event.delta > 0):
        self.canvas.scale("all", event.x, event.y, 1.1, 1.1)
    elif (event.delta < 0):
        self.canvas.scale("all", event.x, event.y, 0.9, 0.9)
    self.canvas.configure(scrollregion = self.canvas.bbox("all"))

I would like to replace "event.x" and "event.y" with window coordinates and not canvas one.

Thanks in advance.

1 Answer 1

1

Just replace all the event.x by event.x_root and event.y by event.y_root and you will have window coordinates .

Sign up to request clarification or add additional context in comments.

1 Comment

You're welcome. I found the information here: infohost.nmt.edu/tcc/help/pubs/tkinter/web/event-handlers.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.