I'm trying to make a minesweeper game, and for that the user needs to be able to set flags. In every minesweeperr game, it works with right click. I tried googling and know how to get coordinates of my mouse cursor, but it works weirdly with buttons. Anywhere else, it gives normal coordinates, but when the cursor is over buttons, it gives me coordiantes between 10 and 30. Why is this? I place the buttons in a loop using .place()
.
Here's the code:
def rightclick(event):
x, y = event.x, event.y
print('{}, {}'.format(x, y))
root.bind('<Button-3>', rightclick)
When I'm not hovering over buttons, it returns normal coordinates like: 452, 539
and 311, 523
But when I am, it returns: 11, 16
and 30, 11
Can someone explain what is going on?