how to add 2 bind events on one button tkinteer

Solutions on MaxInterview for how to add 2 bind events on one button tkinteer by the best coders in the world

showing results for - "how to add 2 bind events on one button tkinteer"
María Paula
10 Jul 2018
1try:
2    import Tkinter as tkinter # for Python 2
3except ImportError:
4    import tkinter # for Python 3
5
6def on_click_1(e):
7    print("First handler fired")
8
9def on_click_2(e):
10    print("Second handler fired")
11
12tk = tkinter.Tk()
13myButton = tkinter.Button(tk, text="Click Me!")
14myButton.pack()
15
16# this first add is not required in this example, but it's good form.
17myButton.bind("<Button>", on_click_1, add="+")
18
19# this add IS required for on_click_1 to remain in the handler list
20myButton.bind("<Button>", on_click_2, add="+")
21
22tk.mainloop()
23
similar questions