Opinionated Qt for Python Light/Dark Theme Toggler
MIT License
Opinionated PySide6 Light/Dark Theme Toggler. Oh wait yet another Qt for Python PySide6 light/dark theme package?
Yes it is!
ATTENTION: This package is designed with writing/deploying standalone PySide6 application in mind.
toggle_theme
function to QtWidgetsLast tested with Python 3.10+ but any Python version that PySide6 supports. Highly recommend using virtual environment when testing/implementing this.
pip install Comel
Clone this repo and copy the comel
package into your project. Ensure both darkdetect
and PySide6
is installed in
your Python environment.
Import ComelMainWindowWrapper
class and connect toggle_theme
to a widget action. That's it!
Refer to examples directory for barebone_app.py
for boilerplate code or takusan_app.py
for a typical PySide app
written from scratch without using Qt Designer.
There is CCheckBox and CRadioButton which uses custom icons and size override. Using the regular QCheckBox and QRadioButton will result in bigger than usual size as it displays the 32x32 size icon image.
# Barebone app
python examples/barebone_app.py
# Takusan app
python examples/takusan_app.py
# Run this for normal and disabled state comparison
python examples/check_disabled_state_app.py
Refer to https://doc.qt.io/qt-6/stylesheet-examples.html for examples on the correct CSS selectors. Search on Stack Overflow/Qt Forum/etc if you cannot find the specific CSS selectors.
base.qss
and presets.py
with the relevant variable and color.generate_qss.py
to generate light.qss
and dark.qss
located in qss/themes
and comel/themes
folder..qrc
into Python file. I might create wrapper classQt is pronounced as "cute". Comel means cute in Bahasa Melayu aka Malay language. Also, the name of my childhood cat.