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

Method tree

rich/layout.py:223–259  ·  view source on GitHub ↗

Get a tree renderable to show layout structure.

(self)

Source from the content-addressed store, hash-verified

221
222 @property
223 def tree(self) -> "Tree":
224 """Get a tree renderable to show layout structure."""
225 from rich.styled import Styled
226 from rich.table import Table
227 from rich.tree import Tree
228
229 def summary(layout: "Layout") -> Table:
230 icon = layout.splitter.get_tree_icon()
231
232 table = Table.grid(padding=(0, 1, 0, 0))
233
234 text: RenderableType = (
235 Pretty(layout) if layout.visible else Styled(Pretty(layout), "dim")
236 )
237 table.add_row(icon, text)
238 _summary = table
239 return _summary
240
241 layout = self
242 tree = Tree(
243 summary(layout),
244 guide_style=f"layout.tree.{layout.splitter.name}",
245 highlight=True,
246 )
247
248 def recurse(tree: "Tree", layout: "Layout") -> None:
249 for child in layout._children:
250 recurse(
251 tree.add(
252 summary(child),
253 guide_style=f"layout.tree.{child.splitter.name}",
254 ),
255 child,
256 )
257
258 recurse(tree, self)
259 return tree
260
261 def split(
262 self,

Callers

nothing calls this directly

Calls 1

TreeClass · 0.90

Tested by

no test coverage detected