Skip to content
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

python3.11 macOS Sonoma tkinter window elements not responding when mouse cursor was inside of tkinter during it's startup #110218

Closed
laggykiller opened this issue Oct 2, 2023 · 15 comments
Assignees
Labels
OS-mac topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@laggykiller
Copy link

laggykiller commented Oct 2, 2023

Bug report

Bug description:

If mouse cursor was inside of tkinter window when tkinter window is opening up, the widgets inside the window become unresponsive (e.g. Click on button not registered). This weird state is resolved when user drag the window, or leaving the tkinter window region for a while.

I discovered this bug in x86_64 macOS 14. I could not reproduce this behavior on arm64 macOS 13 (M1 mac mini)

Any tkinter GUI is affected, even for the demo python3 -m tkinter

To reproduce:

  1. Open terminal
  2. Type python3 -m tkinter
  3. Move the mouse cursor to where the tkinter window will be (Takes some practice and trial & error)
  4. Press enter to launch tkinter
  5. Try to click on button. Button would not respond.
  6. Try to leave the window area, or click on the title bar
  7. Try to click on button again. Button would respond.

CPython versions tested on:

3.11

Operating systems tested on:

macOS

@terryjreedy
Copy link
Member

I cannot reproduce on Windows with 3.11 or 3.12. The window opens in one place and slides diagonally up left to its final position, which varies. I put cursor both at initial window position and within final position and clicks work either way.

@terryjreedy
Copy link
Member

I suspect that this is a bug in tcl/tk in relation to macOS 14 and that we can do nothing here, other than for someone to check tk bug issues.

@laggykiller
Copy link
Author

laggykiller commented Oct 3, 2023

@terryjreedy Thanks for testing. Done a quick lookup on tcltk bug tracker, no similar reported bug.

I have tested with calling tcl directly. Since macOS builtin tcltk is not working (https://stackoverflow.com/a/57750910), I installed tcl-tk using brew, then execute this hello.tcl:

#! /usr/local/bin/wish8.6
button .b -text 0 -command {.b config -text [expr {[.b cget -text]+1}]}
pack   .b ;#RS

This would increase the button text by 1 each time I click it.

I cannot reproduce the problem using this method. This means it's probably problem with python binding to tcltk (_tkinter.c), or something went wrong with the builtin tcltk in python?

btw the brew version of python3 is also affected

@laggykiller
Copy link
Author

@terryjreedy turns out it only affects python3.11. Confirmed that this bug does not exist in 3.8, 3.9, 3.10 (Installed from brew with python and python-tk) and 3.12 (Installed from pkg installer from python.org)

@laggykiller laggykiller changed the title tkinter window elements not responding when mouse cursor was inside of tkinter during it's startup python3.11 x86_64 macOS tkinter window elements not responding when mouse cursor was inside of tkinter during it's startup Oct 3, 2023
@terryjreedy
Copy link
Member

3.11 on Windows with PSF installer is fine.
@ned-deily might know about tcl/tk variations in different Python versions on macos.

@morosebose
Copy link

I've had this bug since updating to Mac OS 14.0 Sonoma. Sadly, it crops up for me even with python 3.10. I tried uninstalling and reinstalling Anaconda, creating new environments with python 3.10 and 3.11, but selecting elements in a list box or clicking on a button is hit-or-miss ever since the upgrade.

@chrstphrchvz
Copy link
Contributor

chrstphrchvz commented Oct 4, 2023

I can reproduce this issue with Tcl/Tk 8.6.12 from the Python 3.11.6 installer, but not Tcl/Tk 8.6.13 from e.g. Homebrew. This issue sounds possibly related to https://core.tcl-lang.org/tk/info/10026855b7 whose reporter confirmed was no longer present in Tcl/Tk 8.6.13. I have not identified the upstream change which likely fixed this.

@laggykiller laggykiller changed the title python3.11 x86_64 macOS tkinter window elements not responding when mouse cursor was inside of tkinter during it's startup python3.11 macOS tkinter window elements not responding when mouse cursor was inside of tkinter during it's startup Oct 8, 2023
@laggykiller laggykiller changed the title python3.11 macOS tkinter window elements not responding when mouse cursor was inside of tkinter during it's startup python3.11 macOS Sonoma tkinter window elements not responding when mouse cursor was inside of tkinter during it's startup Oct 8, 2023
@laggykiller
Copy link
Author

Can confirm that this bug also occurs on arm64 Sonoma

@chrstphrchvz
Copy link
Contributor

Is updating the Python 3.11 macOS installers to Tcl/Tk 8.6.13 an option? There were numerous changes to the Tk Aqua mouse event code between 8.6.12 and 8.6.13, so even if a specific change which fixed this issue is identified, it might not be something that can be directly patched in 8.6.12.

@ned-deily
Copy link
Member

Is updating the Python 3.11 macOS installers to Tcl/Tk 8.6.13 an option?

It does seem that 8.6.13 fixes some issues like this one on macOS so, yes, updating the macOS 3.11 installers seems like a good idea. #110710 has been merged for release in 3.11.7.

@petered
Copy link

petered commented Oct 20, 2023

@terryjreedy turns out it only affects python3.11. Confirmed that this bug does not exist in 3.8, 3.9, 3.10 (Installed from brew with python and python-tk) and 3.12 (Installed from pkg installer from python.org)

I have a user reporting this problem after upgrading to Sonoma. My app uses Python 3.10.11.

@chrstphrchvz
Copy link
Contributor

@terryjreedy turns out it only affects python3.11. Confirmed that this bug does not exist in 3.8, 3.9, 3.10 (Installed from brew with python and python-tk) and 3.12 (Installed from pkg installer from python.org)

I have a user reporting this problem after upgrading to Sonoma. My app uses Python 3.10.11.

Tkinter from Homebrew (python-tk) uses the same Tcl/Tk version (8.6.13) regardless of Python version, whereas Tkinter from python.org installers for Python 3.10 use older Tcl/Tk and are likely affected by this issue.

@bjg2000
Copy link

bjg2000 commented Oct 28, 2023

I also have this issue. I have been developing a very simple professional application for a client for some time now. Never had issues with unresponsive clicks or mouse events until I updated to sonoma a few weeks ago. I have an m1 macbook air and use python 3.11 installed thorugh homebrew. I also get a new error any time I run python code after updating my OS that says

"Python[4896:83817] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES." 

however I think these are unrelated. I run windows through parallels on my mac and tkinter seems to work fine with the windows shell, only a mac sonoma problem.

@laggykiller
Copy link
Author

@bjg2000 the other problem you mentioned belongs to #110950

@VicChorn
Copy link

I had the same issue while running Sonoma/Python 3.10, updating to Python 3.12 using pyenv helped to solve the puzzle with unresponsive buttons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-mac topic-tkinter type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

9 participants