from Tkinter import * #Global variable 'count' stores the number of button clicks count = 0 def button_pressed_cb(root): global count count += 1 print "Hello again - the button was pressed: ", count, " time(s)." root=Tk() button = Button(root,text='Count',command=lambda:button_pressed_cb(root)) button.pack() root.mainloop()