Oct-01-2020, 07:40 PM
Where is drag and drop mentioned?
If you want to force a 3 second continuous touch before doing some action, you'll need to at least bind to touch and release and use an after to call your eventual callback.
If you want to force a 3 second continuous touch before doing some action, you'll need to at least bind to touch and release and use an after to call your eventual callback.
from tkinter import * after_id = None root = Tk() def press_cb(event): global after_id after_id = root.after(3000, after_cb) def release_cb(event): global after_id if after_id is not None: root.after_cancel(after_id) after_id = None def after_cb(): """Do whatever""" print('Leg go of me!!') root.bind('<ButtonPress-1>', press_cb) root.bind('<ButtonRelease-1>', release_cb)Or you could combine a few things.
from tkinter import * root = Tk() def press_cb(event=None): global lp_id if event is None: print('Let go my Eggo!') lp_id = None elif event.type == EventType.ButtonPress: lp_id = root.after(3000, press_cb) elif lp_id: root.after_cancel(lp_id) lp_id = None root.bind('<ButtonPress-1>', press_cb) root.bind('<ButtonRelease-1>', press_cb)It would be useful to know what you are trying to do, what you have tried to do, and why you are unhappy with what you've done. At least I am confused about what you are asking.