Erwan Moalic
Erwan Moalic

Reputation: 25

Find Window's coordinates in tkinter

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.

Upvotes: 1

Views: 207

Answers (1)

j_4321
j_4321

Reputation: 16169

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

Upvotes: 1

Related Questions