Bind mouse button with action function : Mouse « Tkinker « Python Tutorial






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()








18.22.Mouse
18.22.1.Left button clickedLeft button clicked
18.22.2.Right button clickedRight button clicked
18.22.3.Drag with Left buttonDrag with Left button
18.22.4.Middle button clickedMiddle button clicked
18.22.5.Double left clickedDouble left clicked
18.22.6.Mouse events example.Mouse events example.
18.22.7.Mouse button differentiation.Mouse button differentiation.
18.22.8.Bind mouse button with action functionBind mouse button with action function