rich.layout

class rich.layout.ColumnSplitter[source]

Split a layout region in to columns.

divide(children: Sequence[rich.layout.Layout], region: rich.region.Region) Iterable[Tuple[rich.layout.Layout, rich.region.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.

get_tree_icon() str[source]

Get the icon (emoji) used in layout.tree

class rich.layout.Layout(renderable: Optional[Union[rich.console.ConsoleRenderable, rich.console.RichCast, str]] = None, *, name: Optional[str] = None, size: Optional[int] = None, minimum_size: int = 1, ratio: int = 1, visible: bool = True, height: Optional[int] = 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.

add_split(*layouts: Union[rich.layout.Layout, rich.console.ConsoleRenderable, rich.console.RichCast, str]) None[source]

Add a new layout(s) to existing split.

Parameters

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

property children: List[rich.layout.Layout]

Gets (visible) layout children.

get(name: str) Optional[rich.layout.Layout][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[rich.layout.Layout, rich.layout.LayoutRender]

Get a map of the last render.

refresh_screen(console: rich.console.Console, layout_name: str) None[source]

Refresh a sub-layout.

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

  • layout_name (str) – Name of layout.

render(console: rich.console.Console, options: rich.console.ConsoleOptions) Dict[rich.layout.Layout, rich.layout.LayoutRender][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[rich.console.ConsoleRenderable, rich.console.RichCast, str]

Layout renderable.

split(*layouts: Union[rich.layout.Layout, rich.console.ConsoleRenderable, rich.console.RichCast, str], splitter: Union[rich.layout.Splitter, str] = 'column') None[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.

split_column(*layouts: Union[rich.layout.Layout, rich.console.ConsoleRenderable, rich.console.RichCast, str]) None[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.

split_row(*layouts: Union[rich.layout.Layout, rich.console.ConsoleRenderable, rich.console.RichCast, str]) None[source]

Split the layout in tow a row (Layouts side by side).

Parameters

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

property tree: Tree

Get a tree renderable to show layout structure.

unsplit() None[source]

Reset splits to initial state.

update(renderable: Union[rich.console.ConsoleRenderable, rich.console.RichCast, str]) None[source]

Update renderable.

Parameters

renderable (RenderableType) – New renderable object.

exception rich.layout.LayoutError[source]

Layout related error.

class rich.layout.LayoutRender(region: rich.region.Region, render: List[List[rich.segment.Segment]])[source]

An individual layout render.

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: Sequence[rich.layout.Layout], region: rich.region.Region) Iterable[Tuple[rich.layout.Layout, rich.region.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.

get_tree_icon() str[source]

Get the icon (emoji) used in layout.tree

class rich.layout.Splitter[source]

Base class for a splitter.

abstract divide(children: Sequence[rich.layout.Layout], region: rich.region.Region) Iterable[Tuple[rich.layout.Layout, rich.region.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.

abstract get_tree_icon() str[source]

Get the icon (emoji) used in layout.tree