I\'m trying to use the grid_location
method, from the Grid Geometry Manager, in Tkinter, but it seems that I\'m doing something wrong.
Here\'s
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"])