modern_urwid.style.registry

Handles storing styling rules

Classes

StyleRegistry([selectors, pseudos])

Registry for styling rules

class modern_urwid.style.registry.StyleRegistry(selectors: list[tuple] = [], pseudos: dict = {})

Bases: object

Registry for styling rules

Parameters:
  • selectors (list[tuple], optional) – List of starting selectors to register

  • pseudos (dict, optional) – Pseudo class overrides to register

add_selectors(selectors: list[tuple])

Add selectors to the registry

Parameters:

selectors (list[tuple]) – List of selectors to register

get(element: ElementWrapper, default: dict[str, str] = {'background': '', 'background-adv': '', 'color': '', 'color-adv': '', 'monochrome': ''}) tuple[dict[str, str], str, str | None]

Get the style properties and hashes for an element

Parameters:
  • element (cssselect2.tree.ElementWrapper) – The element to lookup styles for

  • default (dict[str, str], optional) – The starting style to override

Returns:

A tuple containing the style properties, the normal style hash, and the focus style hash (if applicable)

Return type:

tuple[dict[str, str], str, str | None]

get_palettes() list[tuple]

Get palettes for registered style rules

Returns:

A list of palettes, in urwid form

Return type:

list[tuple]