PyQt style setter
Currently the only style you can set is dark-gray(pyqt-dark-gray-theme), light-gray(pyqt-light-gray-theme).
- PyQt5 >= 5.8
python -m pip install pyqt-style-setter
- pyqt-dark-gray-theme
- pyqt-light-gray-theme
- pyqt-svg-button - To exclude svg icon set button, also known as
SvgButton. It should use its own style or else svg icon will be disappeared by overwritten style.
StyleSetter.setWindowStyle(main_window: QWidget, theme: str = 'dark', exclude_type_lst: list = [])-main_windowis the widget which user want to set the style.exclude_type_lst's items are excluded from applying style. Item type should betype(ex.QAbstractButton). Currently it only works forQAbstractButton.
※ I use the pyqt-timer's settings dialog as an example.
from PyQt5.QtWidgets import QApplication
from pyqt_timer.settingsDialog import SettingsDialog
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = SettingsDialog()
window.show()
app.exec_()from PyQt5.QtWidgets import QApplication
from pyqt_style_setter import StyleSetter
from pyqt_timer.settingsDialog import SettingsDialog
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = SettingsDialog()
StyleSetter.setWindowStyle(window) # add this
window.show()
app.exec_()Using this with pyqt-custom-titlebar-setter
from PyQt5.QtWidgets import QApplication
from pyqt_custom_titlebar_setter import CustomTitlebarSetter
from pyqt_style_setter import StyleSetter
from pyqt_timer.settingsDialog import SettingsDialog
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
dialog = SettingsDialog()
StyleSetter.setWindowStyle(dialog)
titleBarWindow = CustomTitlebarSetter.getCustomTitleBarWindow(dialog, icon_filename='settings.svg')
titleBarWindow.show()
app.exec_()For those who use macOS
- qtsasstheme - using sass to set qt theme, bit more harder but far more flexible



