rich.tree

class rich.tree.Tree(label, *, style='tree', guide_style='tree.line', expanded=True, highlight=False, hide_root=False)[源代码]

树结构的可渲染对象。

参数
  • label (RenderableType) -- 树标签的可呈现或字符串。

  • style (StyleType, optional) -- 这棵树的样式。默认为“树”。

  • guide_style (StyleType, optional) -- 参考线的样式。默认为“tree.line”。

  • expanded (bool, optional) -- 还可以显示子对象。默认为True。

  • highlight (bool, optional) -- 高亮显示可渲染(如果为str)。默认为False。

  • hide_root (bool) --

add(label, *, style=None, guide_style=None, expanded=True, highlight=False)[源代码]

添加一个子树。

参数
  • label (RenderableType) -- 树标签的可呈现或字符串。

  • style (StyleType, optional) -- 这棵树的样式。默认为“树”。

  • guide_style (StyleType, optional) -- 参考线的样式。默认为“tree.line”。

  • expanded (bool, optional) -- 还可以显示子对象。默认为True。

  • highlight (Optional[bool], optional) -- 高亮显示可渲染(如果为str)。默认为False。

返回

一个新的子树,可以进一步修改。

返回类型

Tree