Opinionated PySide6 Light/Dark Theme Toggler.
Project description
Comel
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.
Features
- Custom QMainWindow widget with built-in light/dark mode toggler. Connect the
toggle_theme
function to QtWidgets callback function and you're done. - Very simple package (for now). Not bloated from trying to cater various Qt for Python packages.
Getting Started
Last tested with Python 3.10+ but any Python version that PySide6 supports. Highly recommend using virtual environment when testing/implementing this.
Install using pip
pip install Comel
Cloning this repo
Clone this repo and copy the comel
package into your project. Ensure both darkdetect
and PySide6
is installed in
your Python environment.
Usage
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.
Custom Widgets
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.
Examples
# 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
Customizing Qt Style Sheets (QSS)
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.
- Edit
base.qss
andpresets.py
with the relevant variable and color. - Run
generate_qss.py
to generatelight.qss
anddark.qss
located inqss/themes
andcomel/themes
folder.
Known Issues
- The default Qt arrow icons does not play nicely when using Qt Style Sheets. While there is a way to bundle custom
icons, I'm not fancy with the extra steps needed to compile Qt
.qrc
into Python file. I might create wrapper class for the affected widgets in future updates. - This library does not cover every single widget styles. Create an issue if you encounter a widget that is missing either light or dark styling.
- QMdiArea and QMdiSubWindow is missing the window resize handle after applying Comel stylesheets. Suspecting one of the selector override to be the root cause.
Why Comel?
Qt is pronounced as "cute". Comel means cute in Bahasa Melayu aka Malay language. Also, the name of my childhood cat.
Credits
- Uses darkdetect for detecting the operating system dark mode.
- Uses icons from Icons8.
- Special thanks to izzthedude for experimenting with this idea.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file comel-0.2.4.tar.gz
.
File metadata
- Download URL: comel-0.2.4.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f65d1230ccf0ec18e96bad46be66a9d8faf4b3ee30d2d63133657a6ed6f54340 |
|
MD5 | 3884c2293b8b04e611415c8ccb07c88e |
|
BLAKE2b-256 | 7e1f02763cec2b14f3b506ba2b369ddd3fad115dc1b162201f507a348b5f7bd2 |
File details
Details for the file Comel-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: Comel-0.2.4-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afb796dd6542d487c66040dc5634b6ffb06dc04d6b985431e17abcc1da49e09a |
|
MD5 | 49370d15192485fcb55d92d40181ffee |
|
BLAKE2b-256 | 17f3eec05ab18aaa374bb17d5f5fcb3ba51ca18571945c1e83f247381533cc13 |