Skip to content

Derive QPalette from current Blender theme - #170

Open
manuelkoester wants to merge 4 commits into
techartorg:masterfrom
manuelkoester:feature/derive_qt_palette
Open

Derive QPalette from current Blender theme#170
manuelkoester wants to merge 4 commits into
techartorg:masterfrom
manuelkoester:feature/derive_qt_palette

Conversation

@manuelkoester

Copy link
Copy Markdown

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
image

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

@manuelkoester

Copy link
Copy Markdown
Author

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/
image

Really not the best example, but it's what came to my mind 😄

@manuelkoester

Copy link
Copy Markdown
Author

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-stylesheet dependency and stop applying an external stylesheet at startup.
  • Add bqt/palette.py to translate Blender theme colors into a Qt QPalette.
  • 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.

Comment thread bqt/__init__.py
Comment on lines +34 to +40
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())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might ignore this since crashes are often easier to debug, and less code is better

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread bqt/__init__.py
Comment on lines 49 to 53
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure why @copilot is suggesting this. this PR doesn't aim to remove the ability to disable stylesheet

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Jerakin

Jerakin commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dynamically support blender themes in the qt stylesheet

4 participants