toga icon indicating copy to clipboard operation
toga copied to clipboard

Tree does not implement styles

Open dwelden opened this issue 1 year ago • 7 comments

Describe the bug

Working on adding a dark mode to an application. All widgets except tree can be restyled with color and background color.

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Tree control should allow changing color and background color.

Screenshots

Screenshot from 2024-11-30 10-35-46

Environment

  • Operating System: Linux Mint 22 (based on Ubuntu Noble)
  • Python version: 3.12.3
  • Software versions:
    • Briefcase: 0.3.20
    • Toga: 0.4.8
    • toga-gtk: 0.4.7 (in pyproject.toml)

Logs


Additional context

No response

dwelden avatar Nov 30 '24 16:11 dwelden

Do other style properties work on Tree on your platform? Font settings, text alignment, dimensions?

HalfWhitt avatar Nov 30 '24 19:11 HalfWhitt

Do other style properties work on Tree on your platform? Font settings, text alignment, dimensions?

font_family and font_weight works. color and background color have no effect. This appears to be using toga-gtk 0.4.7

dwelden avatar Nov 30 '24 22:11 dwelden

Thanks for the report - it seems like there's likely 2 bugs here:

  1. color and background_color not being honoured
  2. dark mode not being honoured with appropriate default colors

The latter might be an issue with the specific GTK theme you're using; if that theme doesn't define a dark mode palette for the Table widget, then the default colors won't follow dark mode.

freakboy3742 avatar Dec 02 '24 00:12 freakboy3742

Honestly I may be misleading by referring to "dark mode" now that I see there are enhancements directed that way. I am just cycling through all widgets and changing color and background color. No themes or other techniques but manual style change.

dwelden avatar Dec 02 '24 01:12 dwelden

Thanks for that detail.

FWIW, I'd strongly recommend that if you're manually tweaking the colors of each individual widget, you're not using Toga the way it was intended to be used. Toga deliberately tries to honor native platform look and feel; to that end, there are some facilities to modify colors on widget, but broadly speaking, they should be considered an edge case for minor UI tweaks, not the basis of a "whole of app theming system".

That doesn't change the fact that what you've found is a bug, and we'll merge a fix if one was submitted as a PR. However, in the scope of the rest of Toga, we consider it a low priority bug, because broadly speaking you shouldn't need to change the colors of widgets. If you don't like the colors that your operating system is providing for apps, take that up with your operating system.

On the other hand, if we're not honoring an OS-level dark mode setting, that would be a bug. However, in this case, it sounds like that isn't what is happening.

freakboy3742 avatar Dec 02 '24 01:12 freakboy3742

Well my concern isn't following OS theme. I want to give the option of toggling between light and dark mode independently of OS setting. Did not find a way other than manually resetting colors. Is there a more Toga-ish approach to that?

dwelden avatar Dec 02 '24 02:12 dwelden

No - because "independent of OS setting" isn't a usage pattern Toga encourages. The OS defines what widgets look like. In Toga's worldview, it's not up to the app designer to determine how the app should look to the user, outside of minor UX-related tweaks (e.g., making text red to make it stand out as an alert). The user is the best arbiter of what their apps should look like, and they can configure their preferences at the operating system level.

freakboy3742 avatar Dec 02 '24 02:12 freakboy3742