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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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