Use lambda to generate a call back function for a button

from Tkinter import *
from sys import stdout, exit
widget = Button(None,
text='Hello event world',
command=(lambda: stdout.write('Hello lambda world\n') or exit()) )
widget.pack()
widget.mainloop()
Related examples in the same category