tkinter_tutorial_7.py (372B)
1 from Tkinter import * 2 3 root = Tk() 4 5 def leftClick(event): 6 print 'Left' 7 8 def middleClick(event): 9 print 'Middle' 10 11 def rightClick(event): 12 print 'Right' 13 14 frame = Frame(root, width = 300, height = 250) 15 frame.bind("<Button-1>", leftClick) 16 frame.bind("<Button-2>", middleClick) 17 frame.bind("<Button-3>", rightClick) 18 frame.pack() 19 20 root.mainloop()