Set the Qt theme (e.g. dark/light/darkblue/lightblue) easily
Project description
qt-sass-theme-getter
Set the Qt theme (e.g. dark/light/darkblue/lightblue) easily
This is using SCSS to set the light/dark theme to PyQt GUI, which is quite efficient.
Setup
python -m pip install qt-sass-theme-getter
Included Packages
-
qtsass - for converting sass into css
-
pyqt-svg-button - for supporting svg button
Method Overview
getThemeFiles(theme: str = 'dark', output_path=os.getcwd())
Supporting theme:
-
dark
-
dark_blue
-
light
-
light_blue
Theme files will be saved in 'res' directory of output_path
after you called getThemeFiles
.
'res' directory looks like this:
ico
directory holds icon files which will be being used in theme. For example, light icons will be being used in dark theme, dark icons will be being used in light theme. _icons.scss
makes sass files in sass
directory refer to icons in this directory.
sass
directory holds the scss files which will be converted into css files.
var
directory holds the _variables.scss
which contains the color(e.g. color of background/widget/border...) variables. You can change the _variables.scss
's variables whatever you want, if you want to set custom variables.
setThemeFiles(main_window: QWidget, input_path='res', exclude_type_lst: list = [])
Right after calling getThemeFiles
, you can set the style with calling setThemeFiles
.
After calling it, 'res' directory looks like this:
scss files successfully convert into css files.
Note: Don't change the current directory with function such as os.chdir
after calling getThemeFiles
and before calling setThemeFiles
. FileNotFoundError
will be most likely occurred.
Example
Code Sample
from PyQt5.QtWidgets import QApplication
from pyqt_timer.settingsDialog import SettingsDialog
from qt_sass_theme_getter import QtSassThemeGetter
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
widget = SettingsDialog()
g = QtSassThemeGetter()
g.getThemeFiles(theme='dark')
# g.getThemeFiles(theme='dark_blue') - if you want to set dark blue theme
g.setThemeFiles(main_window=widget)
widget.show()
app.exec_()
Result
Dark theme
Dark blue theme
Light theme
Light blue theme
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 qt-sass-theme-getter-0.0.33.tar.gz
.
File metadata
- Download URL: qt-sass-theme-getter-0.0.33.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a634cfbe63ca8fe9269b4996c49ee5c9aabfe1a216151ab44152caf08f7dae97 |
|
MD5 | 0e3d50259b67ed2297ae4d8e7e3960e0 |
|
BLAKE2b-256 | acad1d6c4c2edf231333f6a313a59470b2472c2482533f023790e97f7576add5 |
File details
Details for the file qt_sass_theme_getter-0.0.33-py3-none-any.whl
.
File metadata
- Download URL: qt_sass_theme_getter-0.0.33-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3d0a38ed01f432e9c43489043035d4862b3d806bd45a63a9af7157207f44b40 |
|
MD5 | 09450ccdb662d8b09e32416bc49819bc |
|
BLAKE2b-256 | 02ced7919e929793255b09647d43359fd1024dd164982289b26fa9e30c327c58 |