docstring

This commit is contained in:
Will McGugan
2022-11-23 17:14:02 +08:00
parent 66b998dbc1
commit 94ee237ab0

View File

@@ -275,11 +275,17 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
} }
show_root = reactive(True) show_root = reactive(True)
"""bool: Show the root of the tree."""
hover_line = var(-1) hover_line = var(-1)
"""int: The line number under the mouse pointer, or -1 if not under the mouse pointer."""
cursor_line = var(-1) cursor_line = var(-1)
"""int: The line with the cursor, or -1 if no cursor."""
show_guides = reactive(True) show_guides = reactive(True)
"""bool: Enable display of tree guide lines."""
guide_depth = reactive(4, init=False) guide_depth = reactive(4, init=False)
"""int: The indent depth of tree nodes."""
auto_expand = var(True) auto_expand = var(True)
"""bool: Auto expand tree nodes when clicked."""
LINES: dict[str, tuple[str, str, str, str]] = { LINES: dict[str, tuple[str, str, str, str]] = {
"default": ( "default": (
@@ -395,6 +401,8 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
Args: Args:
node (TreeNode[TreeDataType]): A tree node. node (TreeNode[TreeDataType]): A tree node.
base_style (Style): The base style of the widget.
style (Style): The additional style for the label.
Returns: Returns:
Text: A Rich Text object containing the label. Text: A Rich Text object containing the label.
@@ -470,9 +478,11 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
return line.node return line.node
def validate_cursor_line(self, value: int) -> int: def validate_cursor_line(self, value: int) -> int:
"""Prevent cursor line from going outside of range."""
return clamp(value, 0, len(self._tree_lines) - 1) return clamp(value, 0, len(self._tree_lines) - 1)
def validate_guide_depth(self, value: int) -> int: def validate_guide_depth(self, value: int) -> int:
"""Restrict guide depth to reasonable range."""
return clamp(value, 2, 10) return clamp(value, 2, 10)
def _invalidate(self) -> None: def _invalidate(self) -> None: