rich.padding

class rich.padding.Padding(renderable, pad=(0, 0, 0, 0), *, style='none', expand=True)[source]

Draw space around content.

Example

>>> print(Padding("Hello", (2, 4), style="on blue"))
Parameters
  • renderable (RenderableType) – String or other renderable.

  • pad (Union[int, Tuple[int]]) – Padding for top, right, bottom, and left borders. May be specified with 1, 2, or 4 integers (CSS style).

  • style (Union[str, Style], optional) – Style for padding characters. Defaults to “none”.

  • expand (bool, optional) – Expand padding to fit available width. Defaults to True.

classmethod indent(renderable, level)[source]

Make padding instance to render an indent.

Parameters
  • renderable (RenderableType) – String or other renderable.

  • level (int) – Number of characters to indent.

Returns

A Padding instance.

Return type

Padding

static unpack(pad)[source]

Unpack padding specified in CSS style.

Parameters

pad (Union[int, Tuple[int], Tuple[int, int], Tuple[int, int, int, int]]) –

Return type

Tuple[int, int, int, int]