qdarkstyle package

The most complete dark/light style sheet for Qt applications (Qt4, Qt5, PySide, PySide2, PyQt4, PyQt5, QtPy, PyQtGraph, Qt.Py) for Python 2/3 and C++.

Python 2, as well as Qt4 (PyQt4 and PySide), will not be supported anymore. They are still there as it is, but no back-compatibility, fixes, nor features will be implemented.

We still preparing the portability to Qt6 since we need changes in QtPy dependency project.

Check the documentation to see how to set the desirable theme palette.

This module provides a function to load the stylesheets transparently with the right resources file.

First, start importing our module

import qdarkstyle

Then you can get the stylesheet provided by QDarkStyle for various Qt wrappers as shown below

# PySide
dark_stylesheet = qdarkstyle.load_stylesheet_pyside()
# PySide 2
dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
# PyQt4
dark_stylesheet = qdarkstyle.load_stylesheet_pyqt()
# PyQt5
dark_stylesheet = qdarkstyle.load_stylesheet_pyqt5()

Alternatively, from environment variables provided by QtPy, PyQtGraph, Qt.Py

# QtPy
dark_stylesheet = qdarkstyle.load_stylesheet()
# PyQtGraph
dark_stylesheet = qdarkstyle.load_stylesheet(qt_api=os.environ('PYQTGRAPH_QT_LIB'))
# Qt.Py
dark_stylesheet = qdarkstyle.load_stylesheet(qt_api=Qt.__binding__)

Finally, set your QApplication with it

app.setStyleSheet(dark_stylesheet)

Enjoy!

qdarkstyle._apply_application_patches(QCoreApplication, QPalette, QColor, palette)[source]

Apply application-level fixes on the QPalette.

The import names args must be passed here because the import is done inside the load_stylesheet() function, as QtPy is only imported in that moment for setting reasons.

qdarkstyle._apply_binding_patches()[source]

Apply binding-only specific stylesheet patches for the same OS.

Returns:stylesheet string (css).
Return type:str
qdarkstyle._apply_os_patches(palette)[source]

Apply OS-only specific stylesheet patches.

Returns:stylesheet string (css).
Return type:str
qdarkstyle._apply_version_patches(qt_version)[source]

Apply version-only specific stylesheet patches for the same binding.

Parameters:qt_version (str) – Qt string version.
Returns:stylesheet string (css).
Return type:str
qdarkstyle._load_stylesheet(qt_api='', palette=None)[source]

Load the stylesheet based on QtPy abstraction layer environment variable.

If the argument is not passed, it uses the current QT_API environment variable to make the imports of Qt bindings. If passed, it sets this variable and then makes the imports.

Parameters:
  • qt_api (str) – qt binding name to set QT_API environment variable. Default is ‘’. Possible values are pyside, pyside2 pyqt4, pyqt5. Not case sensitive.
  • palette (Palette) – Palette class that inherits from Palette.

Note

  • Note that the variable QT_API is read when first imported. So, pay attention to the import order.
  • If you are using another abstraction layer, i.e PyQtGraph to do imports on Qt things you must set both to use the same Qt binding (PyQt, PySide).
  • OS, binding and binding version number, and application-specific patches are applied in this order.
Returns:stylesheet string (css).
Return type:str
qdarkstyle.load_stylesheet(*args, **kwargs)[source]

Load the stylesheet. Takes care of importing the rc module.

Parameters:
  • pyside (bool) – True to load the PySide (or PySide2) rc file, False to load the PyQt4 (or PyQt5) rc file. Default is False.
  • or
  • qt_api (str) – Qt binding name to set QT_API environment variable. Default is ‘’, i.e PyQt5 the default QtPy binding. Possible values are pyside, pyside2 pyqt4, pyqt5. Not case sensitive.
  • or
  • palette (Palette) – Class (not instance) that inherits from Palette.
Raises:

TypeError – If arguments do not match: type, keyword name nor quantity.

Returns:

the stylesheet string.

Return type:

str

qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=False)[source]

Load the stylesheet from QT_API (or PYQTGRAPH_QT_LIB) environment variable.

Parameters:is_pyqtgraph (bool) – True if it is to be set using PYQTGRAPH_QT_LIB.
Raises:KeyError – if PYQTGRAPH_QT_LIB does not exist.
Returns:the stylesheet string.
Return type:str
qdarkstyle.load_stylesheet_pyqt()[source]

Load the stylesheet for use in a PyQt4 application.

Returns:the stylesheet string.
Return type:str
qdarkstyle.load_stylesheet_pyqt5()[source]

Load the stylesheet for use in a PyQt5 application.

Returns:the stylesheet string.
Return type:str
qdarkstyle.load_stylesheet_pyqt6()[source]

Load the stylesheet for use in a PyQt6 application.

Returns:the stylesheet string.
Return type:str
qdarkstyle.load_stylesheet_pyside()[source]

Load the stylesheet for use in a PySide application.

Returns:the stylesheet string.
Return type:str
qdarkstyle.load_stylesheet_pyside2()[source]

Load the stylesheet for use in a PySide2 application.

Returns:the stylesheet string.
Return type:str
qdarkstyle.load_stylesheet_pyside6()[source]

Load the stylesheet for use in a PySide6 application.

Returns:the stylesheet string.
Return type:str