I'm trying to get the mouse position while pressing a button, but instead of getting the position of the mouse on Tkinter root, it gives me the position of the mouse on the button. For example, if the button is placed on 200, 200, and I press the top left of the button, it prints 0, 0 instead of 200, 200.
import Tkinter as tk
def leftclick(event):
print("left")
x, y = event.x, event.y
print('{}, {}'.format(x, y))
root = tk.Tk()
add_user = tk.Button(root, height=63, width=195 ,text="sign up a user")
add_user.place(x= 20, y = 30)
root.bind("<Button-1>", leftclick)
root.mainloop()
(event)in definition. - Flobleftclickexactly like you posted it, just addingprint(x, y)at the end, and creatig a simple window with a button, it prints the window coordinates, not the button coordinates. - Flob