rich.layout

class rich.layout.ColumnSplitter[source]

Split a layout region in to columns.

divide(children, region)[source]

Divide a region amongst several child layouts.

Parameters
  • children (Sequence(Layout)) – A number of child layouts.

  • region (Region) – A rectangular region to divide.

Return type

Iterable[Tuple[Layout, Region]]

get_tree_icon()[source]

Get the icon (emoji) used in layout.tree

Return type

str

class rich.layout.Layout(renderable=None, *, name=None, size=None, minimum_size=1, ratio=1, visible=True, height=None)[source]

A renderable to divide a fixed height in to rows or columns.

Parameters
  • renderable (RenderableType, optional) – Renderable content, or None for placeholder. Defaults to None.

  • name (str, optional) – Optional identifier for Layout. Defaults to None.

  • size (int, optional) – Optional fixed size of layout. Defaults to None.

  • minimum_size (int, optional) – Minimum size of layout. Defaults to 1.

  • ratio (int, optional) – Optional ratio for flexible layout. Defaults to 1.

  • visible (bool, optional) – Visibility of layout. Defaults to True.

  • height (Optional[int]) –

add_split(*layouts)[source]

Add a new layout(s) to existing split.

Parameters

*layouts (Union[Layout, RenderableType]) – Positional arguments should be renderables or (sub) Layout instances.

Return type

None

property children: List[Layout]

Gets (visible) layout children.

get(name)[source]

Get a named layout, or None if it doesn’t exist.

Parameters

name (str) – Name of layout.

Returns

Layout instance or None if no layout was found.

Return type

Optional[Layout]

property map: Dict[Layout, LayoutRender]

Get a map of the last render.

refresh_screen(console, layout_name)[source]

Refresh a sub-layout.

Parameters
  • console (Console) – Console instance where Layout is to be rendered.

  • layout_name (str) – Name of layout.

Return type

None

render(console, options)[source]

Render the sub_layouts.

Parameters
Returns

A dict that maps Layout on to a tuple of Region, lines

Return type

RenderMap

property renderable: Union[ConsoleRenderable, RichCast, str]

Layout renderable.

split(*layouts, splitter='column')[source]

Split the layout in to multiple sub-layouts.

Parameters
  • *layouts (Layout) – Positional arguments should be (sub) Layout instances.

  • splitter (Union[Splitter, str]) – Splitter instance or name of splitter.

Return type

None

split_column(*layouts)[source]

Split the layout in to a column (layouts stacked on top of each other).

Parameters

*layouts (Layout) – Positional arguments should be (sub) Layout instances.

Return type

None

split_row(*layouts)[source]

Split the layout in to a row (layouts side by side).

Parameters

*layouts (Layout) – Positional arguments should be (sub) Layout instances.

Return type

None

property tree: Tree

Get a tree renderable to show layout structure.

unsplit()[source]

Reset splits to initial state.

Return type

None

update(renderable)[source]

Update renderable.

Parameters

renderable (RenderableType) – New renderable object.

Return type

None

exception rich.layout.LayoutError[source]

Layout related error.

class rich.layout.LayoutRender(region, render)[source]

An individual layout render.

Parameters
property region

Alias for field number 0

property render

Alias for field number 1

exception rich.layout.NoSplitter[source]

Requested splitter does not exist.

class rich.layout.RowSplitter[source]

Split a layout region in to rows.

divide(children, region)[source]

Divide a region amongst several child layouts.

Parameters
  • children (Sequence(Layout)) – A number of child layouts.

  • region (Region) – A rectangular region to divide.

Return type

Iterable[Tuple[Layout, Region]]

get_tree_icon()[source]

Get the icon (emoji) used in layout.tree

Return type

str

class rich.layout.Splitter[source]

Base class for a splitter.

abstract divide(children, region)[source]

Divide a region amongst several child layouts.

Parameters
  • children (Sequence(Layout)) – A number of child layouts.

  • region (Region) – A rectangular region to divide.

Return type

Iterable[Tuple[Layout, Region]]

abstract get_tree_icon()[source]

Get the icon (emoji) used in layout.tree

Return type

str