Skip to content Skip to sidebar Skip to footer

What Is The Difference Between Event.x,event.y And Event.x_root,event.y_root In Tkinter?

import tkinter as tk from tkinter import ttk win=tk.Tk() def get_event(event): print(f'{event.x} {event.y}') win.bind('',get_event) win.mainloop() im making r

Solution 1:

When you use x and y attributes from event, it refers to the x/y coordinate of the mouse at the time of the event, relative to the upper left corner of the widget.

But when you use x_root and y_root from event, it refers to the x/y coordinate of the mouse at the time of the event, relative to the upper left corner of the screen.

Post a Comment for "What Is The Difference Between Event.x,event.y And Event.x_root,event.y_root In Tkinter?"