Title: Tkinter colours wrong on MacOS universal2
Type: Stage: resolved
Components: macOS, Tkinter Versions: Python 3.10, Python 3.9, Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: culler, epaine, ned.deily, ronaldoussoren, serhiy.storchaka, wordtech
Priority: normal Keywords:

Created on 2020-12-02 14:49 by epaine, last changed 2021-01-06 10:55 by epaine. This issue is now closed.

File name Uploaded Description Edit
Screenshot from 2020-12-02 14-37-02.png epaine, 2020-12-02 14:49
Screenshot-2020-12-02-at-12-46-06.png epaine, 2020-12-02 14:50
Messages (21)
msg382315 - (view) Author: E. Paine (epaine) * Date: 2020-12-02 14:49
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.
msg382316 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-12-02 15:07
Are you running in dark mode?
msg382317 - (view) Author: E. Paine (epaine) * Date: 2020-12-02 15:10
> Are you running in dark mode?

Yes. It works fine in light mode.
msg382318 - (view) Author: E. Paine (epaine) * Date: 2020-12-02 15:13
Sorry, that was an important piece of information. It is worth noting that Text widgets correctly change background to black.
msg382321 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-12-02 15:34
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.
msg382326 - (view) Author: E. Paine (epaine) * Date: 2020-12-02 17:09
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.
msg382332 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-12-02 18:00
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.

BTW. @epaine: could you file an issue about this in the Tk tracker if you can reproduce it directly with Tk (without Tkinter)?
msg382333 - (view) Author: E. Paine (epaine) * Date: 2020-12-02 18:11
It seems to be some weird internal mismatch. Code modified from (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("tk::unsupported::MacWindowStyle", "isdark", "."))

I presume this is a MacOS 11 issue. I will look into raising this with the Tk team.
msg382352 - (view) Author: Kevin Walzer (wordtech) * Date: 2020-12-02 22:47
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.
msg382363 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-12-03 01:16
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 installers, or end users to build with an arbitrary checkpoint of the development branch. Even a beta 8.6.11 would be an improvement.
msg382366 - (view) Author: Kevin Walzer (wordtech) * Date: 2020-12-03 02:06
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.
msg382421 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-12-03 15:55
This is a duplicate of #38261.  I'm closing that other issue because this issue has more discussion.
msg382426 - (view) Author: E. Paine (epaine) * Date: 2020-12-03 16:30
> 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)?
msg382433 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-12-03 17:49
It is possible to opt out of dark mode using a key in the Info.plist file. This can also be used in the 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).
msg382443 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-12-03 19:12
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.
msg382454 - (view) Author: Marc Culler (culler) * Date: 2020-12-03 21:07
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.
msg384328 - (view) Author: E. Paine (epaine) * Date: 2021-01-04 15:27
Note: Tcl/Tk 8.6.11 was released a few days ago (thanks Kevin/Marc!).
msg384341 - (view) Author: Marc Culler (culler) * Date: 2021-01-04 18:20
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 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.)
msg384343 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2021-01-04 18:41
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).
msg384347 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-01-04 20:33
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.
msg384487 - (view) Author: E. Paine (epaine) * Date: 2021-01-06 10:55
This does not appear to be a problem anymore on Tk 8.6.11 so I think this issue can be closed.
Date User Action Args
2021-01-06 10:55:33epainesetstatus: open -> closed
resolution: fixed
messages: + msg384487

stage: resolved
2021-01-04 20:33:45ned.deilysetmessages: + msg384347
2021-01-04 18:41:33ronaldoussorensetmessages: + msg384343
2021-01-04 18:20:57cullersetmessages: + msg384341
2021-01-04 15:27:57epainesetmessages: + msg384328
2020-12-03 21:07:43cullersetmessages: + msg382454
2020-12-03 19:12:49ned.deilysetnosy: + culler
messages: + msg382443
2020-12-03 17:49:52ronaldoussorensetmessages: + msg382433
2020-12-03 16:30:17epainesetmessages: + msg382426
2020-12-03 15:57:12ronaldoussorenlinkissue38261 superseder
2020-12-03 15:55:58ronaldoussorensetmessages: + msg382421
2020-12-03 02:06:16wordtechsetmessages: + msg382366
2020-12-03 01:16:45ned.deilysetmessages: + msg382363
2020-12-02 22:47:22wordtechsetnosy: + wordtech
messages: + msg382352
2020-12-02 18:11:26epainesetmessages: + msg382333
2020-12-02 18:00:30ronaldoussorensetmessages: + msg382332
2020-12-02 17:09:28epainesetmessages: + msg382326
2020-12-02 15:34:07ronaldoussorensetmessages: + msg382321
2020-12-02 15:13:52epainesetmessages: + msg382318
2020-12-02 15:10:57epainesetmessages: + msg382317
2020-12-02 15:07:41ronaldoussorensetmessages: + msg382316
2020-12-02 14:50:06epainesetfiles: + Screenshot-2020-12-02-at-12-46-06.png
2020-12-02 14:49:55epainecreate