Skip to content
Mihaly Konda edited this page Jul 9, 2025 · 2 revisions

theme

version: v1.1.7

A module for setting a pre-defined theme to Qt objects.


object WidgetTheme

Singleton object of the type _WidgetTheme, containing the types defined in the source JSON file.


function get_theme_types()

def get_theme_types(fetch_data: bool = False) -> list[str | ThemeParameters]

Returns the available themes.

Parameters:

  • fetch_data: A flag requesting the ThemeParameters objects themselves. The default is False.

dataclass ThemeParameters

Dataclass for storing the palette parameter values to a given theme (to LIGHT, by default).

Parameters:

  • src_file: Path to the source file containing theme data.

def __post_init__(self) -> None

Defines the default colours.


def write_json(self, destination: str) -> None

Writes the content to a JSON file.

Parameters:

  • destination: Path where the file should be written to.

class _WidgetTheme(metaclass=Singleton)

A class for Enum-like access to themes.


def __init__(self) -> None

Initializer for the class.


    def __getattr__(self, name: str) -> ThemeParameters

Handles an attribute access request. (It expects that at least one theme file exists!)

Parameters:

  • name: The name of the requested theme.

Returns: A stored set of parameters of a theme.


def load_dict(self) -> None

Loads the content of theme JSONs into the internal dictionary.


function set_widget_theme()

def set_widget_theme(widget: QWidgetT, theme: ThemeParameters = None) -> None

Sets a QWidget's palette to values defined by the theme.

Parameters:

  • widget: A widget whose palette is to be set to the requested theme.
  • theme: The theme to set for the widget. The default is None, which makes the function try to read the set theme property of the widget.

API reference

Base/technical modules:

Other modules

Clone this wiki locally