I'm developing a small interface in Tkinter
, but I have the following doubt: Is there a mouse event that allows an action to be performed after two consecutive clicks on a button?
I'm developing a small interface in Tkinter
, but I have the following doubt: Is there a mouse event that allows an action to be performed after two consecutive clicks on a button?
There is, yes, the method bind
, you can inform the event, which can be:
<Button-1>
: A click . <Double-Button-1>
: Two clicks . <Triple-Button-1>
: Three clicks . See an example:
from tkinter import *
def foo():
print ('foo')
root = Tk()
frame = Frame(root)
frame.pack()
button1 = Button(frame, text = 'Foo!')
button1.pack()
button1.bind('<Double-Button-1>', foo)
root.mainloop()
For more information, see the documentation: Events and Bindings .