Skip to main content

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

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:

image

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:

image

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

image

Dark blue theme

image

Light theme

image

Light blue theme

image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qt-sass-theme-getter-0.0.33.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

qt_sass_theme_getter-0.0.33-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file qt-sass-theme-getter-0.0.33.tar.gz.

File metadata

File hashes

Hashes for qt-sass-theme-getter-0.0.33.tar.gz
Algorithm Hash digest
SHA256 a634cfbe63ca8fe9269b4996c49ee5c9aabfe1a216151ab44152caf08f7dae97
MD5 0e3d50259b67ed2297ae4d8e7e3960e0
BLAKE2b-256 acad1d6c4c2edf231333f6a313a59470b2472c2482533f023790e97f7576add5

See more details on using hashes here.

File details

Details for the file qt_sass_theme_getter-0.0.33-py3-none-any.whl.

File metadata

File hashes

Hashes for qt_sass_theme_getter-0.0.33-py3-none-any.whl
Algorithm Hash digest
SHA256 d3d0a38ed01f432e9c43489043035d4862b3d806bd45a63a9af7157207f44b40
MD5 09450ccdb662d8b09e32416bc49819bc
BLAKE2b-256 02ced7919e929793255b09647d43359fd1024dd164982289b26fa9e30c327c58

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page