qdarktheme#

qdarktheme is a python module to apply original theme to PySide and PyQt.

qdarktheme.load_stylesheet(theme: str = 'dark', corner_shape: str = 'rounded', custom_colors: Optional[dict[str, str]] = None, *, border: Optional[str] = None) str[source]#

Load the style sheet which looks like flat design. There are dark and light theme.

Parameters
  • theme – The name of the theme. There are dark and light theme.

  • corner_shape – The corner shape. There are rounded and sharp shape.

  • custom_colors – The custom color map. Overrides the default color for color id you set.

  • border – The corner shape. There are rounded and sharp shape. This argument is deprecated since v1.2.0. Please use corner_shape instead. This argument override value of argument corner_shape.

Raises
  • ValueError – If the arguments of this method is wrong.

  • KeyError – If the color id of custom_colors is wrong.

Returns

The stylesheet string for the given arguments.

Examples

Set stylesheet to your Qt application.

  1. Dark Theme

    app = QApplication([])
    app.setStyleSheet(qdarktheme.load_stylesheet())
    # or
    app.setStyleSheet(qdarktheme.load_stylesheet("dark"))
    
  2. Light Theme

    app = QApplication([])
    app.setStyleSheet(qdarktheme.load_stylesheet("light"))
    
  3. Sharp corner

    # Change corner shape to sharp.
    app = QApplication([])
    app.setStyleSheet(qdarktheme.load_stylesheet(corner_shape="sharp"))
    
  4. Customize color

    app = QApplication([])
    app.setStyleSheet(qdarktheme.load_stylesheet(custom_colors={"primary": "#D0BCFF"}))
    
qdarktheme.load_palette(theme: str = 'dark', custom_colors: Optional[dict[str, str]] = None)[source]#

Load the QPalette for the dark or light theme.

Parameters
  • theme – The name of the theme. Available theme are dark and light.

  • custom_colors – The custom color map. Overrides the default color for color id you set.

Raises
  • TypeError – If the arg name of theme is wrong.

  • KeyError – If the color id of custom_colors is wrong.

Returns

The QPalette for the given theme.

Return type

QPalette

Examples

Set QPalette to your Qt application.

  1. Dark Theme

    app = QApplication([])
    app.setPalette(qdarktheme.load_palette())
    # or
    app.setPalette(qdarktheme.load_palette("dark"))
    
  2. Light Theme

    app = QApplication([])
    app.setPalette(qdarktheme.load_palette("light"))
    
  3. Customize color

    app = QApplication([])
    app.setPalette(custom_colors={"primary": "#D0BCFF"})
    
qdarktheme.get_themes() tuple[str, ...][source]#

Return available theme names.

Returns

Tuple of available theme names.

qdarktheme.clear_cache() None[source]#

Clear the caches in system home path.

PyQtDarkTheme build the caches of resources in the system home path. You can clear the caches by running this method.