rich.tree

class rich.tree.Tree(label, *, style='tree', guide_style='tree.line', expanded=True, highlight=False, hide_root=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.

  • hide_root (bool) –

Return type

None

add(label, *, style=None, guide_style=None, expanded=True, highlight=False)[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