当前位置:   article > 正文

Tkinter教程之Event篇(1)'_tkinter event

tkinter event
''' 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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/124929
推荐阅读
相关标签
  

闽ICP备14008679号