rich.tree

class rich.tree.Tree(label: Union[rich.console.ConsoleRenderable, rich.console.RichCast, str], *, style: Union[str, rich.style.Style] = 'tree', guide_style: Union[str, rich.style.Style] = 'tree.line', expanded: bool = True, highlight: bool = False)[source]

A renderable for a tree structure.

Parameters
  • label (RenderableType) – The renderable or str for the tree label.

  • style (StyleType, optional) – Style of this tree. Defaults to “tree”.

  • guide_style (StyleType, optional) – Style of the guide lines. Defaults to “tree.line”.

  • expanded (bool, optional) – Also display children. Defaults to True.

  • highlight (bool, optional) – Highlight renderable (if str). Defaults to False.

add(label: Union[rich.console.ConsoleRenderable, rich.console.RichCast, str], *, style: Optional[Union[str, rich.style.Style]] = None, guide_style: Optional[Union[str, rich.style.Style]] = None, expanded: bool = True, highlight: bool = False) rich.tree.Tree[source]

Add a child tree.

Parameters
  • label (RenderableType) – The renderable or str for the tree label.

  • style (StyleType, optional) – Style of this tree. Defaults to “tree”.

  • guide_style (StyleType, optional) – Style of the guide lines. Defaults to “tree.line”.

  • expanded (bool, optional) – Also display children. Defaults to True.

  • highlight (Optional[bool], optional) – Highlight renderable (if str). Defaults to False.

Returns

A new child Tree, which may be further modified.

Return type

Tree