tkinter - Widget does not detect entry of mouse when the mouse is held down before entering widget

淺唱寂寞╮ 提交于 2019-12-08 05:30:04

问题


How can I trigger an event that fires when the mouse enters a widget (e.g. a Frame) while the mouse is held down? It seems that the event in question only fires when the mouse is up.

I'm using this code (approximately) so far:

self._root_window = tkinter.Tk()
self._root_frame = tkinter.Frame()
self._root_frame.pack(fill=tkinter.X, padx=5, pady=5)
frame = tkinter.Frame(master=self._root_frame, ...)

self._root_window.bind('<Button-1>', self._on_button_down)
self._root_window.bind('<ButtonRelease-1>', self._on_button_up)
frame.bind('<Enter>', self._on_mouse_enter)

I'm also tracking whether the mouse is down or up using a boolean variable.

How come the <Enter> event requires that the mouse is up?

来源:https://stackoverflow.com/questions/48029920/tkinter-widget-does-not-detect-entry-of-mouse-when-the-mouse-is-held-down-befo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!