I'd like to know if there is a way to set a limit to the .scan_dragto
method in tkinter.
In my current project, using .scan_dragto
correctly drags my canvas widget. But I can drag it endlessly. Is there any way to limit this drag?
I've already tried to set a max size to my canvas using maxsize
, but it didn't work.
This part of my code is something like this one below.
import tkinter as tk
root = tk.Tk()
img = tk.Canvas(root, bg = "white", width = 1100, height = 600)
img.grid()
#Some canvas objects
#...
img.bind('<ButtonPress-1>', lambda event: img.scan_mark(event.x, event.y))
img.bind("<B1-Motion>", lambda event: img.scan_dragto(event.x, event.y, gain=1))
root.mainloop()