tkinter_tutorial_6.py (423B)
1 from Tkinter import * 2 3 root = Tk() 4 5 def bindedFunc(): 6 print 'Tast' 7 return 8 9 def printStuff(event): 10 print 'Hello welt' 11 return 12 13 #Binding a function to a (button) widget: 14 button_1 = Button(root, text="Print Tast", command=bindedFunc) 15 16 # Method two: 17 button_2 = Button(root, text="Print some stuff") 18 button_2.bind("<Button-1>", printStuff) 19 20 button_1.pack() 21 button_2.pack() 22 23 root.mainloop()