Reputation: 1121
I have a widget and want its binding to handle two distinct events in order to call a function.
Widget.bind("<Event-1>", "<Event-2>", any_func)
and any_func
may only be called if <Event-1>
is followed by <Event-2>
How this can be done?
Upvotes: 1
Views: 365
Reputation: 385820
Just put them together in one string, with or without whitespace between each event:
import Tkinter as tk
root = tk.Tk()
text = tk.Text(root)
text.pack(fill="both", expand=True)
def insert_surprise(event):
text.insert("insert", "surprise!")
text.bind("<Key-a> <Key-b>", insert_surprise)
root.mainloop()
Upvotes: 1