rich.padding

class rich.padding.Padding(renderable: RenderableType, pad: PaddingDimensions = 0, 0, 0, 0, *, style: Union[str, rich.style.Style] = 'none', expand: bool = 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: RenderableType, level: int)Padding[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: Union[int, Tuple[int], Tuple[int, int], Tuple[int, int, int, int]]) → Tuple[int, int, int, int][source]

Unpack padding specified in CSS style.