FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[ENH]: Tool icons are hardly visible in Tk when using a dark theme · Issue #22150 · matplotlib/matplotlib · GitHub

Repository navigation

[ENH]: Tool icons are hardly visible in Tk when using a dark theme #22150

Closed

Description

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().

Activity

  1. timhoffm commented on Jan 8, 2022

    MemberAuthor

    @daniilS you seem knowledgeable in Tk and care for improving it. Do you know if this is possible in Tk?

  2. daniilS commented on Jan 8, 2022

    Contributor

    @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.

  3. timhoffm commented on Jan 8, 2022

    MemberAuthor

    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

    icon_color = self.palette().color(self.foregroundRole())

    and

    fg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)

  4. daniilS commented on Jan 8, 2022

    Contributor

    @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 _backend_ttk when I have a few free days...), but I wrote up a quick fix in #22163 that checks the background colour of the button, and changes the icon colour to the button's text colour if the background's HSV Value is under 50%.

    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?

  5. timhoffm commented on Jan 9, 2022

    MemberAuthor

    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.

  6. QuLogic commented on Jan 11, 2022

    Member

    that reminds me, I've been meaning to write a _backend_ttk when I have a few free days...,

    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)

  7. daniilS commented on Jan 11, 2022

    Contributor

    @QuLogic a toggle button can be created easily by using ttk.Checkbutton(..., style="Toolbutton"). The main reason I was considering this is because I wanted to write a Tk equivalent of qt_editor, for which I'd be using Ttk, and at that point it would be good to make the toolbar's look consistent with it. The only big difference between a Tk and Ttk toolbar would be how they respond to user themes though, so I'm not sure how many users would even notice the change.

  8. QuLogic commented on Jan 11, 2022

    Member

    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.

  9. daniilS commented on Jan 11, 2022

    Contributor

    @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.

  10. added this to the v3.6.0 milestone on Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL