rich.theme

class rich.theme.Theme(styles: Mapping[str, Union[str, Style]] = None, inherit: bool = True)[source]

A container for style information, used by Console.

Parameters
  • styles (Dict[str, Style], optional) – A mapping of style names on to styles. Defaults to None for empty styles.

  • inherit (bool, optional) – Inherit default styles. Defaults to True.

property config

Get contents of a config file for this theme.

classmethod from_file(config_file: IO[str], source: str = None, inherit: bool = True)rich.theme.Theme[source]

Load a theme from a text mode file.

Parameters
  • config_file (IO[str]) – An open conf file.

  • source (str, optional) – The filename of the open file. Defaults to None.

  • inherit (bool, optional) – Inherit default styles. Defaults to True.

Returns

A New theme instance.

Return type

Theme

classmethod read(path: str, inherit: bool = True)rich.theme.Theme[source]

Read a theme from a path.

Parameters
  • path (str) – Path to a config file readable by Python configparser module.

  • inherit (bool, optional) – Inherit default styles. Defaults to True.

Returns

A new theme instance.

Return type

Theme