rich.theme

class rich.theme.Theme(styles=None, inherit=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 a theme with no styles.

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

property config: str

Get contents of a config file for this theme.

classmethod from_file(config_file, source=None, inherit=True)[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, inherit=True)[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