Mega Code Archive

 
Categories / Python Tutorial / Tkinker
 

Bind mouse button with action function

from Tkinter  import *       def hello(event):     print 'Press twice to exit'       def quit(event):                    print 'Hello, I must be going...'      import sys; sys.exit()        widget = Button(None, text='Hello event world') widget.pack() widget.bind('<Button-1>', hello)       widget.bind('<Double-1>', quit)        widget.mainloop()