Derive QPalette from current Blender theme - #170
Conversation
|
We deployed this to production a bit ago and I'm happy to say that it works really well. Can't really show our UIs, but here is the spyder CodeEditor with https://extensions.blender.org/themes/midnight-blue-theme/ Really not the best example, but it's what came to my mind 😄 |
|
Just a prod update @hannesdelbeke / @Jerakin (apologies for the ping 🙈 ) We have been rolling with this in prod for a bit longer than the MR and it's been working really well! Definitely a drastic change in terms of style, but in all the UIs we have and I tested, it consistently looked more native (at least imo). Even with the default blender theme |
There was a problem hiding this comment.
Pull request overview
This PR switches BQt theming from applying a static Qt stylesheet dependency to deriving a QPalette from Blender’s active UI theme and applying it to the global QApplication, so Qt widgets better match the user’s chosen Blender theme.
Changes:
- Remove the
blender-qt-stylesheetdependency and stop applying an external stylesheet at startup. - Add
bqt/palette.pyto translate Blender theme colors into a QtQPalette. - Apply the derived palette during application instantiation and update README to reflect the new theming approach.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| README.md | Updates feature description to reflect palette-based theming from Blender’s current theme. |
| pyproject.toml | Removes the blender-qt-stylesheet dependency now that theming is palette-based. |
| bqt/palette.py | Introduces palette derivation logic from Blender theme widget/UI colors into a QPalette. |
| bqt/init.py | Replaces stylesheet application with palette application during QApplication instantiation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _apply_palette() -> None: | ||
| """Style the QApplication with a palette derived from Blender's theme.""" | ||
| from bqt.palette import build_blender_palette | ||
|
|
||
| app = QApplication.instance() | ||
|
|
||
| app.setPalette(build_blender_palette()) |
There was a problem hiding this comment.
might ignore this since crashes are often easier to debug, and less code is better
There was a problem hiding this comment.
Yeah agreed, the QApp should really exist at this point anyway
The function is also marked private so it shouldn't be touched outside its current singular callsite
| def _instantiate_q_application() -> bqt.blender_applications.BlenderApplication: | ||
| _enable_dpi_scale() | ||
| app = _load_os_module() | ||
| if os.getenv("BQT_NO_STYLESHEET", "0") == "1": | ||
| logger.info("BQT_NO_STYLESHEET set, skipping stylesheet.") | ||
| else: | ||
| _apply_stylesheet(app) | ||
| _apply_palette() | ||
| return app |
There was a problem hiding this comment.
unsure why @copilot is suggesting this. this PR doesn't aim to remove the ability to disable stylesheet
There was a problem hiding this comment.
Yeah not sure.. The other env var could have some value, but that can also easily be added later when needed. Personally we have not had the need as stylesheets nicely layer on top
|
Thumbs up from me. I like this dynamic approach here. Not only does it keep to the users choice but if Blender ever changes colors this updates with it. Issues might arise if Blender starts changing the attribute names, but I think that's unlikely. |

This is the MR for #169 . Should also close #79
This moves away from the current static stylesheet approach to read Blender theme colors and apply them to a QPalette on the QApp. All child windows will then inherit from it and it all falls nicely into place hehe
Very heavily inspired by/ported from https://github.com/minimalefforttech/blender_qt/tree/main/blender_qt/theme
For now this MR is mainly for demonstration and I assume there would need to be done some additional changes.
Example screenshot with the https://extensions.blender.org/themes/catppucin4blender/ theme

Please give it a squeeze and let me know what you think!