This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Button clicked failed when mouse hover tooltip and tooltip destroyed
Type: behavior Stage: test needed
Components: Tkinter Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jason990420, PySimpleGUI, jim.wygralak, ned.deily, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-12-26 10:39 by Jason990420, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
Linux3.10.jpg PySimpleGUI, 2022-02-06 19:13 Screenshot of PySimpleGUI Test harness showing Python & tk version numbers.
Messages (10)
msg409188 - (view) Author: Jason Yang (Jason990420) * Date: 2021-12-26 10:39
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.

```python
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()
```

```python
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
msg412263 - (view) Author: PySimpleGUI (PySimpleGUI) Date: 2022-02-01 14:07
This issue is impacting multiple PySimpleGUI users in particular.  One commented today:  
"I already spent a day trying to figure out what was happening to my UI when I found this open issue."
Until a fix is found, I'm going to add a specific check for 8.6.12 and disable the tooltip feature and issue a warning to users as to why.  Not sure what other options are available at the moment.
msg412279 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-02-01 15:29
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?
msg412337 - (view) Author: Jason Yang (Jason990420) * Date: 2022-02-02 05:29
The platform is WIN10 which shown at last line in first message.
I don't have other platforms to test if ok or not.
msg412351 - (view) Author: PySimpleGUI (PySimpleGUI) Date: 2022-02-02 12:05
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.
msg412656 - (view) Author: PySimpleGUI (PySimpleGUI) Date: 2022-02-06 19:13
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.
msg415344 - (view) Author: PySimpleGUI (PySimpleGUI) Date: 2022-03-16 14:48
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.

https://user-images.githubusercontent.com/46163555/158422534-964b7edb-f845-468b-adba-57f9139009c4.mp4
msg416675 - (view) Author: Jim Wygralak (jim.wygralak) Date: 2022-04-04 15:32
DATA:
Just chiming in to report that I'm seeing this issue with the following freshly installed:
Python 3.10.4
tkinter 8.6.12
PySimpleGUI 4.57.0
OS is Windows 10

As others have report it is related to the cursor entering the tool tip box before clicking the button.

OBSERVATIONS:
I've noticed that the tool tip always seems to appear up and to the right of the cursor. If I approach the button by moving the cursor down & left, the tool tip appears when the cursor enters the button, then as I continue to move the cursor to the center of the button I'm moving AWAY FROM the tool tip, and the issue doesn't appear.

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.
msg416713 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-04-05 01:44
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.

https://mail.python.org/mailman/listinfo/tkinter-discuss
msg416941 - (view) Author: PySimpleGUI (PySimpleGUI) Date: 2022-04-07 20:22
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!
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90338
2022-04-07 20:22:30PySimpleGUIsetmessages: + msg416941
2022-04-05 01:44:20ned.deilysetmessages: + msg416713
2022-04-04 15:32:45jim.wygralaksetnosy: + jim.wygralak
messages: + msg416675
2022-03-16 14:48:18PySimpleGUIsetmessages: + msg415344
2022-02-06 19:13:13PySimpleGUIsetfiles: + Linux3.10.jpg

messages: + msg412656
2022-02-02 12:05:32PySimpleGUIsetmessages: + msg412351
2022-02-02 05:29:28Jason990420setmessages: + msg412337
2022-02-01 15:29:16ned.deilysetnosy: + ned.deily
messages: + msg412279
2022-02-01 14:07:02PySimpleGUIsetnosy: + PySimpleGUI
messages: + msg412263
2021-12-31 21:39:45terry.reedysetnosy: + serhiy.storchaka
stage: test needed
type: crash -> behavior

versions: + Python 3.11, - Python 3.8
2021-12-26 10:39:08Jason990420create