New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Button clicked failed when mouse hover tooltip and tooltip destroyed #90338
Comments
Button no response when clicked if mouse move into tooltip and tooltip destroyed for Python 3.9.9/3.10.1 and tkinter 8.6.12 You can check it by moving mouse into button, then move to tooltip after it shown, then click button and you won't get response for button clicked, but "Leave". It is OK for lower version of Python/tkinter. import sys
from datetime import datetime
import tkinter as tk
class Tooltip(object):
"""
create a tooltip for a given widget
"""
def __init__(self, widget, text='widget info'):
self.waittime = 500 # miliseconds
self.widget = widget
self.text = text
self.widget.bind("<Enter>", self.enter)
self.widget.bind("<Leave>", self.leave)
self.widget.bind("<ButtonPress>", self.leave)
self.id = None
self.top = None
def enter(self, event=None):
print(now(), "Enter")
self.schedule()
def leave(self, event=None):
print(now(), "Leave")
self.unschedule()
self.hidetip()
def schedule(self):
self.unschedule()
self.id = self.widget.after(self.waittime, self.showtip)
def unschedule(self):
id = self.id
self.id = None
if id:
self.widget.after_cancel(id)
def showtip(self, event=None):
x = y = 0
x, y, cx, cy = self.widget.bbox("insert")
x += self.widget.winfo_rootx() + self.widget.winfo_width()//2
y += self.widget.winfo_rooty() + self.widget.winfo_height()//2
self.top = tk.Toplevel(self.widget)
self.top.wm_overrideredirect(True)
self.top.wm_geometry("+%d+%d" % (x, y))
label = tk.Label(self.top, text=self.text, bd=1, font=font, relief='solid')
label.pack(ipadx=1)
def hidetip(self):
top = self.top
self.top = None
if top:
top.destroy()
def now():
return datetime.now().strftime("%H:%M:%S")
print(f"Python version : {sys.version.split(' ')[0]}")
print(f"tkinter version: {tk.Tcl().eval('info patchlevel')}")
font = ("Courier New", 40)
root = tk.Tk()
button = tk.Button(root, text="button", font=font,
command=lambda:print(now(), 'Button clicked'))
button.pack(padx=10, pady=5)
tooltip = Tooltip(button, 'This is button 1')
root.mainloop() d:\>python test.py
Python version : 3.10.1
tkinter version: 8.6.12
18:21:52 Enter (Mouse to button)
18:21:54 Leave (mouse to tooltip)
18:21:55 Leave (button clicked get no response)
18:21:57 Leave (button clicked get no response)
18:21:58 Leave (button clicked get no response)
d:\>python test.py
Python version : 3.9.9
tkinter version: 8.6.12
18:22:51 Enter (Mouse to button)
18:22:54 Leave (mouse to tooltip)
18:22:55 Leave (button clicked get no response)
18:22:56 Leave (button clicked get no response)
18:22:57 Leave (button clicked get no response)
d:\>python test.py
Python version : 3.8.10
tkinter version: 8.6.9
18:23:22 Enter (Mouse to button)
18:23:23 Leave (mouse to tooltip)
18:23:23 Enter (mouse stay, and it will repeat `Enter and Leave` again and again)
18:23:24 Leave
...
18:23:28 Enter
18:23:28 Leave
18:23:28 Button clicked (button clicked get response)
18:23:31 Leave
18:23:31 Button clicked (button clicked get response)
18:23:32 Leave Platform - WIN10 |
This issue is impacting multiple PySimpleGUI users in particular. One commented today: |
Can you say which platforms are affected by this? The OP's example appears to be from a Windows system. Are Unix (X11) and/or macOS versions of Tk affected, too? |
The platform is WIN10 which shown at last line in first message. |
I'll do some Linux testing today to see if I can replicate it. There was another problem reported that only on 8.6.12 on Mac (sorry, don't mean to muddy the waters by mentioning it). The reason I bring it up is that I've not seen a tkinter release have these specific kinds of problems in a very long time and am wondering if something was changed internally that could have an impact on this problem. I'll report back with what I find on Linux. Thank you SO much for giving this problem some attention. |
I'm sorry for not getting back quicker on the Linux testing. I've not figured out how to get 8.6.12 up and running on my Linux environment. I've tried both Python 3.9 and Python 3.10 and neither have 8.6.12. |
We've been able to verify this is a problem on Windows, Mac and Linux using the code that Jason posted earlier. Here's a video of the behavior on Linux. The problem you'll see is that button click events stop being generated. I'm hoping this is a symptom of a larger problem as there are other problems we've seen on 8.6.12. This is unusual as tkinter has been rock solid since I've been using it over the past few years. |
DATA: As others have report it is related to the cursor entering the tool tip box before clicking the button. OBSERVATIONS: However, if I approach the button by moving the cursor up and to the right, the tool tip appears as the cursor enters the button, and it overlaps the button. As I continue to move the cursor to the center of the button, it enters the tool tip box and triggers this fault. The only 100% effective workaround appears to be not using tooltips. That is a loss of function, and not an acceptable long term solution. |
Unfortunately, this is the kind of issue, often the case with tkinter issues, where it is difficult to know where the problem might be. While I know little about the internals of tkinter and Tk, my intuition is that this is most likely a Tk issue and would need to be resolved by the Tk folks. For these kinds of problems, it is usually helpful to try to reproduce the problem using Tcl and Tk directly; I have no idea how difficult that would be in this case. If someone can do so, then it would be much more likely to get the Tk project to look into it (by opening an issue with them). Another ofter useful approach is to ask on the tkinter mailing list or on StackOverflow where people with both tkinter and Tk expertise hang out. |
Hi Ned... thank you kindly for the response. Code was provided on Dec 26, 2021 that reproduces the problem. We've taken the extra step of verifying on Linux and Mac that indeed the problem is on those operating systems as well. I'm struggling to understand why it's now suggested that the way to get help from the tkinter team is to also produce code directly in TCl/TK directly or that posts on StackOverflow would be of help. It appears to be a bug that's in the lower-level code that happened between releases 8.6.11 and 8.6.12. We're not looking for a workaround, which I suppose is the purpose of posting on StackOverflow, we're looking for a fix. We're doing our best to follow solid best practices of reproducing problems, providing code to demonstrate the bug, and using the official bug reporting mechanism (bugs.python.org). Any help that can be provided in getting the right persons from the tkinter team responsible for the code is greatly appreciated. Greatly appreciated! |
I too encountered this deficiency. Unreliable event notification is as serious as it gets. I had to switch tool-kits. Is there any estimate of when this might be fixed? Thanks. |
I am also experiencing this issue which makes me keep my system on older releases of Python to keep my application working as expected, otherwise my UI is unusable due to frequency the buttons do not work when clicking on them. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: