'''
Tkinter教程之Event篇(1)
'''
# 事件的使用方法
''' 1.测试鼠标点击(Click)事件 '''
# -*- coding: cp936 -*-
# <Button-1>:鼠标左击事件
# <Button-2>:鼠标中击事件
# <Button-3>:鼠标右击事件
# <Double-Button-1>:双击事件
# <Triple-Button-1>:三击事件
from Tkinter import *
root = Tk()
def printCoords(event):
print event.x,event.y
# 创建第一个Button,并将它与左键事件绑定
bt1 = Button(root,text = ' leftmost button ' )
bt1.bind( ' <Button-1> ' ,printCoords)
# 创建二个Button,并将它与中键事件绑定
bt2 = Button(root,text = ' middle button
# 事件的使用方法
''' 1.测试鼠标点击(Click)事件 '''
# -*- coding: cp936 -*-
# <Button-1>:鼠标左击事件
# <Button-2>:鼠标中击事件
# <Button-3>:鼠标右击事件
# <Double-Button-1>:双击事件
# <Triple-Button-1>:三击事件
from Tkinter import *
root = Tk()
def printCoords(event):
print event.x,event.y
# 创建第一个Button,并将它与左键事件绑定
bt1 = Button(root,text = ' leftmost button ' )
bt1.bind( ' <Button-1> ' ,printCoords)
# 创建二个Button,并将它与中键事件绑定
bt2 = Button(root,text = ' middle button