python_tkinter_鼠标点击事件

Posted 做梦者造梦

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python_tkinter_鼠标点击事件相关的知识,希望对你有一定的参考价值。

from tkinter import *
def callback(event):
   print("at",event.x,event.y)

root = Tk()
root.title("鼠标点击事件")
frame = Frame(root,width=300,height=180)
frame.bind("<Button-1>",callback)
frame.pack()
frame2 = Frame(root,width=300,height=180,bg="lightblue")
frame2.pack()

root.mainloop()

 

以上是关于python_tkinter_鼠标点击事件的主要内容,如果未能解决你的问题,请参考以下文章