Package: qtsasstheme
qtsassthemeSet the Qt theme (e.g. darkgray/lightgray/darkblue/lightblue) easilyThis is using SCSS to set the light/dark theme to PyQt GUI, which is quite efficient.Old name of this isqt-sass-theme-getter.Setupgit clone ~(recommended)python -m pip install qtsasstheme- install as pypi package (good for test only)Using withpyinstallermake main.py inside the qtsasstheme directorypython -m PyInstaller main.py --add-data "qt_sass_theme;./qt_sass_theme"(if your main script is main.py)go to the dist/test folder and start the *.exe fileIncluded Packagesqtpy- support pyqt5/pyside2/pyqt6/pyside6qtsass- for converting sass into cssDetailed DescriptionMethod OverviewgetThemeFiles(theme: str = 'dark_gray', font=QFont('Arial', 9), background_darker=False, output_path=os.getcwd())Currently there are 4 official theme being supported:dark_graydark_bluelight_graylight_blueYou can also make your own theme withcustomizing theme.background_darkerdecides whether the background color is going to be darker than general widget color or not.If that is set toTrue, background color is darker than general widget color. See image below.If that is set toFalse(which is set by default), background color is lighter than general widget color. See image below.output_pathis the path that 'res' directory will be made which is holding a bunch of theme files after you calledgetThemeFiles.'res' directory looks like below.icodirectory 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.scssmakes sass files insassdirectory refer to icons in this directory.sassdirectory holds the scss files which will be converted into css files.vardirectory holds the_variables.scsswhich contains the color(e.g. color of background/widget/border...) variables.setThemeFiles(main_window: QWidget, input_path='res')Right after callinggetThemeFiles, you can set the style with callingsetThemeFiles.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 asos.chdirafter callinggetThemeFilesand before callingsetThemeFiles.FileNotFoundErrorwill be most likely occurred.Customizing ThemeThere are two ways to customize theme.1. Giving color string togetThemeFilesYou can give the 6-digit hex string(e.g. #FF0000) togetThemeFiles'sthemeargument.In this case, widget's color will be set based on the hex color you given.This is the way how to do it://..app=QApplication(sys.argv)w=SampleWidget()g=QtSassTheme()g.getThemeFiles(theme='#6f495f')g.setThemeFiles(w)w.show()app.exec()2. Modify_variables.scss's color directlyThis is the way how to do it:CallinggetThemeFilesg=QtSassTheme()g.getThemeFiles()'res' directory like above will be generated. You can see_variables.scss.Change the variablesopen the_variables.scssand change the$bgcolor's value.This is_variables.scss's contents(dark-gray theme).$bgcolor:#555555;$widgetcolor:darken($bgcolor,10);$altwidgetcolor:lighten($widgetcolor,18);$textcolor:#DDDDDD;$hovercolor:lighten($widgetcolor,6);$bordercolor:lighten($widgetcolor,20);$selectcolor:darken($widgetcolor,6);$disabledcolor:#AAAAAA;$textwidgetcolor:darken($widgetcolor,12);$scrollhandlecolor:lighten($widgetcolor,30);$splitterhandlecolor:darken($widgetcolor,10);You can change any colors.In this example i will change the $bgcolor from #555555 to #006600(dark-green).CallingsetThemeFiles//..app=QApplication(sys.argv)w=SampleWidget()g=QtSassTheme()g.setThemeFiles(w)w.show()app.exec()ExampleCode SamplefromPyQt5.QtWidgetsimportQApplication# from PyQt6.QtWidgets import QApplication# from PySide2.QtWidgets import QApplication# from PySide6.QtWidgets import QApplicationfrompyqt_timer.settingsDialogimportSettingsDialogfromqt_sass_themeimportQtSassThemeif__name__=="__main__":importsysapp=QApplication(sys.argv)widget=SettingsDialog()g=QtSassTheme()g.getThemeFiles(theme='dark_gray')# g.getThemeFiles(theme='dark_blue') - if you want to set dark blue themeg.setThemeFiles(main_window=widget)widget.show()app.exec()ResultPreview widget ispyqt-timer's settings dialog.Dark gray themeDark blue themeLight gray themeLight blue theme