【发布时间】:2020-05-25 20:45:53
【问题描述】:
我正在尝试制作一个 python 脚本,如果您将鼠标放在 tkinter 中的某个元素上会发生某些事情。我知道我可以创建一个通过 after 重复的函数并创建一个 if statement 但我认为那里可能是一种更简单的方法。 HTML 中的onmouseover 事件就是我想要的一个例子。
提前致谢!
我的代码:
from tkinter import Tk, Canvas, PhotoImage
root=Tk()
c=Canvas(root, width=500, height=500) # width and height are placeholders here
root.title("wdihihfwaheuih") # the title too
imag = PhotoImage(file="example.pgm")
image = c.create_image(250, 250, anchor="c", image=imag) # <-- element i want to "onmouseover"
root.mainloop()
【问题讨论】:
-
我读了,没有任何帮助
-
是的,谢谢
-
这能回答你的问题吗? How to bind events to Canvas items?
标签: python tkinter mouseevent