style_sheet

Module Contents

StyleSheetManager

Style sheet manager

QssTemplate

style sheet template

StyleSheetBase

Style sheet base class

FluentStyleSheet

Fluent style sheet

StyleSheetFile

Style sheet file

CustomStyleSheet

Custom style sheet

CustomStyleSheetWatcher

Custom style sheet watcher

DirtyStyleSheetWatcher

Dirty style sheet watcher

StyleSheetCompose

Style sheet compose

ThemeColor

Theme color type

applyThemeColor(qss)

apply theme color to style sheet

getStyleSheetFromFile(file)

get style sheet from qss file

getStyleSheet(source[, theme])

get style sheet

setStyleSheet(widget, source[, theme, register])

set the style sheet of widget

setCustomStyleSheet(widget, lightQss, darkQss)

set custom style sheet

addStyleSheet(widget, source[, theme, register])

add style sheet to widget

updateStyleSheet([lazy])

update the style sheet of all fluent widgets

setTheme(theme[, save, lazy])

set the theme of application

toggleTheme([save, lazy])

toggle the theme of application

themeColor()

get theme color

setThemeColor(color[, save, lazy])

set theme color

class StyleSheetManager

Bases: PyQt5.QtCore.QObject

Style sheet manager

register(source, widget: PyQt5.QtWidgets.QWidget, reset=True)

register widget to manager

Parameters

source: str | StyleSheetBase

qss source, it could be: * str: qss file path * StyleSheetBase: style sheet instance

widget: QWidget

the widget to set style sheet

reset: bool

whether to reset the qss source

deregister(widget: PyQt5.QtWidgets.QWidget)

deregister widget from manager

items()
source(widget: PyQt5.QtWidgets.QWidget)

get the qss source of widget

styleSheetManager
class QssTemplate(template)

Bases: string.Template

style sheet template

delimiter = '--'
applyThemeColor(qss: str)

apply theme color to style sheet

Parameters

qss: str

the style sheet string to apply theme color, the substituted variable should be equal to the value of ThemeColor and starts width , i.e –ThemeColorPrimary

class StyleSheetBase

Style sheet base class

abstract path(theme=Theme.AUTO)

get the path of style sheet

content(theme=Theme.AUTO)

get the content of style sheet

apply(widget: PyQt5.QtWidgets.QWidget, theme=Theme.AUTO)

apply style sheet to widget

class FluentStyleSheet

Bases: StyleSheetBase, enum.Enum

Fluent style sheet

MENU = 'menu'
LABEL = 'label'
PIVOT = 'pivot'
BUTTON = 'button'
DIALOG = 'dialog'
SLIDER = 'slider'
INFO_BAR = 'info_bar'
SPIN_BOX = 'spin_box'
TAB_VIEW = 'tab_view'
TOOL_TIP = 'tool_tip'
CHECK_BOX = 'check_box'
COMBO_BOX = 'combo_box'
FLIP_VIEW = 'flip_view'
LINE_EDIT = 'line_edit'
LIST_VIEW = 'list_view'
TREE_VIEW = 'tree_view'
INFO_BADGE = 'info_badge'
PIPS_PAGER = 'pips_pager'
TABLE_VIEW = 'table_view'
CARD_WIDGET = 'card_widget'
TIME_PICKER = 'time_picker'
COLOR_DIALOG = 'color_dialog'
MEDIA_PLAYER = 'media_player'
SETTING_CARD = 'setting_card'
TEACHING_TIP = 'teaching_tip'
FLUENT_WINDOW = 'fluent_window'
SWITCH_BUTTON = 'switch_button'
MESSAGE_DIALOG = 'message_dialog'
STATE_TOOL_TIP = 'state_tool_tip'
CALENDAR_PICKER = 'calendar_picker'
FOLDER_LIST_DIALOG = 'folder_list_dialog'
SETTING_CARD_GROUP = 'setting_card_group'
EXPAND_SETTING_CARD = 'expand_setting_card'
NAVIGATION_INTERFACE = 'navigation_interface'
path(theme=Theme.AUTO)

get the path of style sheet

class StyleSheetFile(path: str)

Bases: StyleSheetBase

Style sheet file

path(theme=Theme.AUTO)

get the path of style sheet

class CustomStyleSheet(widget: PyQt5.QtWidgets.QWidget)

Bases: StyleSheetBase

Custom style sheet

DARK_QSS_KEY = 'darkCustomQss'
LIGHT_QSS_KEY = 'lightCustomQss'
path(theme=Theme.AUTO)

get the path of style sheet

__eq__(other: object) bool

Return self==value.

setCustomStyleSheet(lightQss: str, darkQss: str)

set custom style sheet in light and dark theme mode

setLightStyleSheet(qss: str)

set the style sheet in light mode

setDarkStyleSheet(qss: str)

set the style sheet in dark mode

lightStyleSheet() str
darkStyleSheet() str
content(theme=Theme.AUTO) str

get the content of style sheet

class CustomStyleSheetWatcher

Bases: PyQt5.QtCore.QObject

Custom style sheet watcher

eventFilter(obj: PyQt5.QtWidgets.QWidget, e: PyQt5.QtCore.QEvent)
class DirtyStyleSheetWatcher

Bases: PyQt5.QtCore.QObject

Dirty style sheet watcher

eventFilter(obj: PyQt5.QtWidgets.QWidget, e: PyQt5.QtCore.QEvent)
class StyleSheetCompose(sources: List[StyleSheetBase])

Bases: StyleSheetBase

Style sheet compose

content(theme=Theme.AUTO)

get the content of style sheet

add(source: StyleSheetBase)

add style sheet source

remove(source: StyleSheetBase)

remove style sheet source

getStyleSheetFromFile(file: str | PyQt5.QtCore.QFile)

get style sheet from qss file

getStyleSheet(source: str | StyleSheetBase, theme=Theme.AUTO)

get style sheet

Parameters

source: str | StyleSheetBase
qss source, it could be:
  • str: qss file path

  • StyleSheetBase: style sheet instance

theme: Theme

the theme of style sheet

setStyleSheet(widget: PyQt5.QtWidgets.QWidget, source: str | StyleSheetBase, theme=Theme.AUTO, register=True)

set the style sheet of widget

Parameters

widget: QWidget

the widget to set style sheet

source: str | StyleSheetBase
qss source, it could be:
  • str: qss file path

  • StyleSheetBase: style sheet instance

theme: Theme

the theme of style sheet

register: bool

whether to register the widget to the style manager. If register=True, the style of the widget will be updated automatically when the theme changes

setCustomStyleSheet(widget: PyQt5.QtWidgets.QWidget, lightQss: str, darkQss: str)

set custom style sheet

Parameters

widget: QWidget

the widget to add style sheet

lightQss: str

style sheet used in light theme mode

darkQss: str

style sheet used in light theme mode

addStyleSheet(widget: PyQt5.QtWidgets.QWidget, source: str | StyleSheetBase, theme=Theme.AUTO, register=True)

add style sheet to widget

Parameters

widget: QWidget

the widget to set style sheet

source: str | StyleSheetBase
qss source, it could be:
  • str: qss file path

  • StyleSheetBase: style sheet instance

theme: Theme

the theme of style sheet

register: bool

whether to register the widget to the style manager. If register=True, the style of the widget will be updated automatically when the theme changes

updateStyleSheet(lazy=False)

update the style sheet of all fluent widgets

Parameters

lazy: bool

whether to update the style sheet lazily, set to True will accelerate theme switching

setTheme(theme: qfluentwidgets.common.config.Theme, save=False, lazy=False)

set the theme of application

Parameters

theme: Theme

theme mode

save: bool

whether to save the change to config file

lazy: bool

whether to update the style sheet lazily, set to True will accelerate theme switching

toggleTheme(save=False, lazy=False)

toggle the theme of application

Parameters

save: bool

whether to save the change to config file

lazy: bool

whether to update the style sheet lazily, set to True will accelerate theme switching

class ThemeColor

Bases: enum.Enum

Theme color type

PRIMARY = 'ThemeColorPrimary'
DARK_1 = 'ThemeColorDark1'
DARK_2 = 'ThemeColorDark2'
DARK_3 = 'ThemeColorDark3'
LIGHT_1 = 'ThemeColorLight1'
LIGHT_2 = 'ThemeColorLight2'
LIGHT_3 = 'ThemeColorLight3'
name()

The name of the Enum member.

color()
themeColor()

get theme color

setThemeColor(color, save=False, lazy=False)

set theme color

Parameters

color: QColor | Qt.GlobalColor | str

theme color

save: bool

whether to save to change to config file

lazy: bool

whether to update the style sheet lazily