问题
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