Set the Qt theme (e.g. dark/light/darkblue/lightblue) easily
Project description
qtsasstheme
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.
Old name of this is qt-sass-theme-getter
.
Setup
python -m pip install qtsasstheme
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 import QtSassTheme
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
widget = SettingsDialog()
g = QtSassTheme()
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
Hashes for qtsasstheme-0.0.33-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56e985ffb2406aa0012439258698a7ccff8b35555860b842641c6c4a9f1ec690 |
|
MD5 | 0db8b195d32f3805f068291a1e74e46e |
|
BLAKE2b-256 | 80bacdb825ca82ab9017c7cf3d8c6c3c1fb189768d643de715f943ed442237f0 |