Navigation Menu

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

Tkinter colours wrong on MacOS universal2 #86707

Closed
E-Paine mannequin opened this issue Dec 2, 2020 · 21 comments
Closed

Tkinter colours wrong on MacOS universal2 #86707

E-Paine mannequin opened this issue Dec 2, 2020 · 21 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes OS-mac topic-tkinter

Comments

@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Dec 2, 2020

BPO 42541
Nosy @ronaldoussoren, @ned-deily, @serhiy-storchaka, @E-Paine
Files
  • Screenshot from 2020-12-02 14-37-02.png
  • Screenshot-2020-12-02-at-12-46-06.png
  • 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:

    assignee = None
    closed_at = <Date 2021-01-06.10:55:33.181>
    created_at = <Date 2020-12-02.14:49:55.609>
    labels = ['OS-mac', '3.8', 'expert-tkinter', '3.9', '3.10']
    title = 'Tkinter colours wrong on MacOS universal2'
    updated_at = <Date 2021-01-06.10:55:33.181>
    user = 'https://github.com/E-Paine'

    bugs.python.org fields:

    activity = <Date 2021-01-06.10:55:33.181>
    actor = 'epaine'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-01-06.10:55:33.181>
    closer = 'epaine'
    components = ['macOS', 'Tkinter']
    creation = <Date 2020-12-02.14:49:55.609>
    creator = 'epaine'
    dependencies = []
    files = ['49645', '49646']
    hgrepos = []
    issue_num = 42541
    keywords = []
    message_count = 21.0
    messages = ['382315', '382316', '382317', '382318', '382321', '382326', '382332', '382333', '382352', '382363', '382366', '382421', '382426', '382433', '382443', '382454', '384328', '384341', '384343', '384347', '384487']
    nosy_count = 6.0
    nosy_names = ['ronaldoussoren', 'wordtech', 'ned.deily', 'culler', 'serhiy.storchaka', 'epaine']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue42541'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Dec 2, 2020

    When using tkinter from the universal2 package, the colours are completely confused. Most text tries to white, even though the background is light and this makes text in Entries completely unreadable (where the background is white). This affects both Tk and Ttk.

    The first included screenshot is of a simple script which just creates a Tk label and Ttk label. The second screenshot is of the IDLE 'open module' interface in which I have typed 'test' (though, you cannot see this).

    The main problem is that I cannot check whether this is a Tkinter or Tk issue as ActiveTcl only offers 8.6.9 and I haven't yet compiled my own copy of Tk.

    This is not a problem on the standard installer.

    @E-Paine E-Paine mannequin added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes OS-mac topic-tkinter labels Dec 2, 2020
    @ronaldoussoren
    Copy link
    Contributor

    Are you running in dark mode?

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Dec 2, 2020

    Are you running in dark mode?

    Yes. It works fine in light mode.

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Dec 2, 2020

    Sorry, that was an important piece of information. It is worth noting that Text widgets correctly change background to black.

    @ronaldoussoren
    Copy link
    Contributor

    The problem seems to be that the window background doesn't adjust to dark mode, while the window contents does.

    I don't know if we should do something in Tkinter for this.

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Dec 2, 2020

    I just compiled Tk 8.6.10 and it has the same problems. So the question now is whether we work-around it in Tkinter/IDLE or close this issue as third party.

    @ronaldoussoren
    Copy link
    Contributor

    With some luck it might be possible to work around this. If it isn’t we should at least opt out of dark mode for IDLE by changing its Info.plist.

    https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_macos_app

    https://wiki.tcl-lang.org/page/Tk+differences+on+Mac+OS+X

    BTW. @epaine: could you file an issue about this in the Tk tracker if you can reproduce it directly with Tk (without Tkinter)?

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Dec 2, 2020

    It seems to be some weird internal mismatch. Code modified from https://wiki.tcl-lang.org/page/Tk+differences+on+Mac+OS+X (see following) suggests that dark mode is not enabled for the window (and yet we are getting white foreground colours)

    import tkinter as tk
    root = tk.Tk()
    print(root.tk.call("tk::unsupported::MacWindowStyle", "isdark", "."))

    I presume this is a MacOS 11 issue. I will look into raising this with the Tk team.

    @wordtech
    Copy link
    Mannequin

    wordtech mannequin commented Dec 2, 2020

    This bug is not present in IDLE 3.9.0 when built against the tip of Tk core-8-6-branch. Marc Culler has done some work to fix the visual artifacts, and the work continues. The problem here is that Apple's API churn continually breaks parts of Tk with each new OS release, and there is large amount of work just to keep things working reasonably.

    @ned-deily
    Copy link
    Member

    Thanks for checking, Kevin. Is there any update on when we can expect a Tk 8.6.11? It's been over a year now since 8.6.10 and there have been so many macOS-related changes that have gone into Tk since then. It's really not fair to ask downstream packagers, like us for the python.org installers, or end users to build with an arbitrary checkpoint of the development branch. Even a beta 8.6.11 would be an improvement.

    @wordtech
    Copy link
    Mannequin

    wordtech mannequin commented Dec 3, 2020

    Ned, I wish I knew. Marc and I are both now members of the TCT, and have had a few conversations around the release schedule, but the release schedule is more or less determined when one or two senior members of the TCT decide things are ready. We had some momentum toward an RC of 8.6.11 a few months ago, but that seems to have stalled out.

    @ronaldoussoren
    Copy link
    Contributor

    This is a duplicate of bpo-38261. I'm closing that other issue because this issue has more discussion.

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Dec 3, 2020

    we should at least opt out of dark mode for IDLE
    That still leaves tkinter almost unusable when dark mode is turned on. I am looking into solutions but am not hopeful (maybe we should ask Marc?).

    @ned, what are the alternatives if we decide 8.6.10 is not the way to go (do we go back to 8.6.8/9 or forward and use an arbitrary checkpoint assuming 8.6.11 is not happening soon)? Also, are we intending to provide a universal2 installer for 3.9.1 (i.e. we need to sort this asap)?

    @ronaldoussoren
    Copy link
    Contributor

    It is possible to opt out of dark mode using a key in the Info.plist file. This can also be used in the Python.app hidden in the framework to globally disable support for dark mode.

    I wouldn't switch back to 8.6.9, if only because that doesn't build properly on macOS 11 (and hence would make building the "univeral2" installer a lot harder).

    I'd rather use the tip of the 8.6.x branch for Tk to get the latest bug fixes (probably picking a specific commit to be able to reproduce the build).

    @ned-deily
    Copy link
    Member

    I agree that moving forward (using an unreleased 8.6.10+ snapshot) is better than moving backwards (back to 8.6.9). Perhaps Marc or Kevin can suggest Tcl and Tk dev heads to use.

    @culler
    Copy link
    Mannequin

    culler mannequin commented Dec 3, 2020

    Yes, I can provide a good commit ID to work with. Please give me a couple of days. The current tip is almost an ideal choice. There have been no Aqua bug reports for quite some time. But now there is one new one (from Kevin) so I'd like to fix that, discuss with Kevin, and test.

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Jan 4, 2021

    Note: Tcl/Tk 8.6.11 was released a few days ago (thanks Kevin/Marc!).

    @culler
    Copy link
    Mannequin

    culler mannequin commented Jan 4, 2021

    Well, actually the release was announced today.

    There was one bug fix which did not make it into the release but could possibly affect Python, due to the fact that Python is installed as a framework, and frameworks to not have icons. I can supply a (1-line) patch if needed. To test, import tkinter, create a tkinter.Tk object and open the "About Python" menu. If the icon displayed on the About dialog looks like a folder then you need the patch.

    Please let me know what happens when switching to dark mode. My concern
    arises from my understanding that python is being built with a macOS 10.9 SDK, which does not understand dark mode. I don't know what will happen when running that code on a system which does support dark mode. Since Tk can be build on Big Sur with a minimum target of 10.9 (and I recommend doing so) I think it should be OK. There may be warnings when linking _tkinter.so though.

    I do not understand why the 10.9 SDK is needed, since I recently built Python 3.9.0 on Big Sur, with a minimum target of 10.9, and did not see any significant issues. (Well, maybe A few warnings from the posix module need investigation.)

    @ronaldoussoren
    Copy link
    Contributor

    W.r.t. building on 10.9: until very recently (trunk and 3.9.1) Python didn’t check for symbol availability at runtime. Building on 10.9 is basically a workaround for that.

    The, for now experimental, “universal2” installer for 3.9.1 is build on Big Sur and includes Tk 8.6.10 (and we’ll track Tk releases now that we have a more modern build system).

    @ned-deily
    Copy link
    Member

    As Ronald notes, as of 3.9.1, we are for the immediate future providing two macOS installer variants: the traditional 10.9+ Intel-64 variant that is built on 10.9 and includes Tk 8.6.8 and the new "experimental" 10.9+ "universal2" (Apple Silicon and Intel-64) variant built on macOS 11 which included Tk 8.6.10. As the new universal2 variant gains more exposure over the next releases of 3.9.x, we hope to migrate to that being the recommended variant and start to deprecate the traditional 10.9 variant for 3.9.x. For 3.10 pre-releases, we are now only providing the "universal2" variant; the next alpha release. 3.10.0a4, should be available very shortly and its macOS installer is built with the just released Tk 8.6.11. I have only run some preliminary tests at the moment and there do seem to be some changes and possible regressions in our tests when using 8.6.11 instead of 8.6.10 but I will investigate further over the next day or so and open issues as needed. Feel free to download 3.10.0a4 and test away!

    I did not see any issues with missing icons; with a Python framework build, Python and IDLE both run under app bundles with supplied icons amd that still seems to be working. Things may well be different for non-framework builds but they were before, too.

    @E-Paine
    Copy link
    Mannequin Author

    E-Paine mannequin commented Jan 6, 2021

    This does not appear to be a problem anymore on Tk 8.6.11 so I think this issue can be closed.

    @E-Paine E-Paine mannequin closed this as completed Jan 6, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes OS-mac topic-tkinter
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants