MCPcopy
hub / github.com/Textualize/rich / add

Method add

rich/tree.py:55–84  ·  view source on GitHub ↗

Add a child tree. Args: 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".

(
        self,
        label: RenderableType,
        *,
        style: Optional[StyleType] = None,
        guide_style: Optional[StyleType] = None,
        expanded: bool = True,
        highlight: Optional[bool] = False,
    )

Source from the content-addressed store, hash-verified

53 self.hide_root = hide_root
54
55 def add(
56 self,
57 label: RenderableType,
58 *,
59 style: Optional[StyleType] = None,
60 guide_style: Optional[StyleType] = None,
61 expanded: bool = True,
62 highlight: Optional[bool] = False,
63 ) -> "Tree":
64 """Add a child tree.
65
66 Args:
67 label (RenderableType): The renderable or str for the tree label.
68 style (StyleType, optional): Style of this tree. Defaults to "tree".
69 guide_style (StyleType, optional): Style of the guide lines. Defaults to "tree.line".
70 expanded (bool, optional): Also display children. Defaults to True.
71 highlight (Optional[bool], optional): Highlight renderable (if str). Defaults to False.
72
73 Returns:
74 Tree: A new child Tree, which may be further modified.
75 """
76 node = Tree(
77 label,
78 style=self.style if style is None else style,
79 guide_style=self.guide_style if guide_style is None else guide_style,
80 expanded=expanded,
81 highlight=self.highlight if highlight is None else highlight,
82 )
83 self.children.append(node)
84 return node
85
86 def __rich_console__(
87 self, console: "Console", options: "ConsoleOptions"

Callers 13

test_render_asciiFunction · 0.95
test_render_tree_win32Function · 0.95
test_tree_measureFunction · 0.95
walk_directoryFunction · 0.80
extractMethod · 0.80
recurseMethod · 0.80
tree.pyFile · 0.80

Calls 2

TreeClass · 0.85
appendMethod · 0.45

Tested by 8

test_render_asciiFunction · 0.76
test_render_tree_win32Function · 0.76
test_tree_measureFunction · 0.76