Buttons have their own coordinate system according to the "grid_location" method? Buttons have their own coordinate system according to the "grid_location" method? tkinter tkinter

Buttons have their own coordinate system according to the "grid_location" method?


You are correct that each button "has it's own coordinate system". More accurately, though, the event.x and event.y values are relative to the widget associated with the event rather than the widget's parent or the root window.

If you really do need the row and column that the widget is in you can use grid_info to get the row and column of the widget associated with the event. For example:

def mouse(event):    grid_info = event.widget.grid_info()    print("row:", grid_info["row"], "column:", grid_info["column"])