Get a tree renderable to show layout structure.
(self)
| 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, |