try: import Tkinter as tkinter # for Python 2 except ImportError: import tkinter # for Python 3 def on_click_1(e): print("First handler fired") def on_click_2(e): print("Second handler fired") tk = tkinter.Tk() myButton = tkinter.Button(tk, text="Click Me!") myButton.pack() # this first add is not required in this example, but it's good form. myButton.bind("
Here is what the above code is Doing:
1. Create a button
2. Bind the button to a handler
3. Bind the button to a second handler
4. Start the main loop
When the button is clicked, both handlers are called.
The add=”+” is required for the second bind to work.
If you remove the add=”+” from the second bind, only the second handler will be called.