-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Tool icons are hardly visible in Tk when using a dark theme #22150
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
Comments
@daniilS you seem knowledgeable in Tk and care for improving it. Do you know if this is possible in Tk? |
@timhoffm not that straightforward in pure Tk, but since we're already using Pillow it's very easy. Did you set the background colour for the buttons manually, or is there some function that sets it? So I know where to check for the button background colour. |
The icon background is transparent, so it effectively uses the theme background. We color the icon with the window text color. Relying on the theme colors will give a reasonable contrast and consistent look. See
and matplotlib/lib/matplotlib/backends/backend_wx.py Line 1127 in bf3c651
|
@timhoffm Ah, I get what you're asking. Tk doesn't have a proper application-wide theme without using Ttk (that reminds me, I've been meaning to write a I've tested it briefly and it seems to work, but I don't have any realistic use-cases to test it with because in my app I've monkey-patched the backend to use ttk. Could you test it with any real-life cases you're aware of? Also, question: is there a reason for limiting this to just dark themes? |
This was discovered and fixed for the specific case: "Our icons are hardly visible in dark themes, let's make them light there" #14810. This is the minimal workaround to fix the default icons and reduce the likelihood of messing up user icons. Let's move further discussion to #22164. |
I have attempted this before, but the toggle buttons don't look great, as Ttk doesn't support turning off the check box. Here is a backwards-incompatible start at it: QuLogic@3ec45d8 (pulled out of my stashes, which conflicted and maybe I didn't fix properly) |
@QuLogic a toggle button can be created easily by using |
Ah, thanks, that looks better. I guess I should clean up that branch and make it actually backwards-compatible. Theming may sound minor, but it looks far better on Windows, for example. |
@QuLogic For the default popup window, even the current backend can look modern with just a few tiny tweaks: see #22174. The one case where Ttk does make a big difference for me was when I'm embedding matplotlib and using themes for the rest of the application (such as ttkbootstrap), which makes the toolbar look rather out of place. In terms of backwards compatibility, I was considering making a separate backend for Ttk, but since most of the backend is private, dropping support for Tk 8.4 (8.5 which brings Ttk was released in 2007...) could make things a lot easier if you want to just switch to Ttk entirely. |
Problem
The icons are hard-coded to be black and blend into the backgound:
Proposed solution
For wx and Qt, we modify the color to be light when a dark backgound is present; see the
_icon()
methods in these backends.It would be nice to have something similar for Tk as well.
This needs somebody with knowledge in Tk. Marking as good first issue because one does not need to understand anything about Matplotlib. The button icon is set in
NavigationToolbar2Tk._set_image_for_button()
.The text was updated successfully, but these errors were encountered: