import tkinter as tk from time import sleep def start_drag(event): global current_coords global dragged_item dragged_item = label current_coords = label.winfo_pointerx(), label.winfo_pointery() def stop_drag(event): dragged_item = None def drag(event): global current_coords xc, yc = label.winfo_pointerx(), label.winfo_pointery() dx, dy = xc - current_coords[0], yc - current_coords[1] current_coords = xc, yc label.place(x=label.winfo_x() + dx, y=label.winfo_y() + dy) def nn(root,im): global label image = tk.PhotoImage(file=im) # Use self.image label = tk.Label(root, image=image) label.image = image # Keep a reference to the image label.pack() dragged_item = None current_coords = 0, 0 label.bind('', start_drag) label.bind('', stop_drag) label.bind('', drag) # globals().update(locals()) while True: tk.Misc.lift(label) sleep(0.05) print("Image cords: ", label.winfo_x(), 720 - label.winfo_y() - image.height()) #x1, y1 = image.coords(image) # print(f'Image cords: {}')