buffalo_panel.app.tui.SimulationTree
- class buffalo_panel.app.tui.SimulationTree(label, data=None, *, name=None, id=None, classes=None, disabled=False)[source]
Bases:
Tree[SimulationNodeData]Widget for navigating the simulation configuration hierarchy.
Methods
find_node_by_path(path)Return the first tree node whose stored path matches
path.rebuild(manager[, cursor_path])Re-populate the tree from the current simulation data.
Attributes
Defines default logic to allow the widget to be maximized.
Does this widget support automatic text selection? May be further refined with [Widget.allow_select][textual.widget.Widget.allow_select].
Title of widget used where bindings are displayed (such as in the key panel).
Is this widget blank (no border, no content)? Enable for very large scrolling containers.
Initial value for border_subtitle attribute.
Initial value for border_title attribute.
Default classes argument if not supplied.
Default TCSS.
Should focusable widgets be automatically focused on click? Default return value of [Widget.focus_on_click][textual.widget.Widget.focus_on_click].
Optional help text shown in help panel (Markdown format).
Unicode 'icon' to use for an expandable node.
Unicode 'icon' to use for an expanded node.
LINESShould default css be limited to the widget type?
Check if horizontal scroll is permitted.
Check if the widget may be maximized.
Check if this widget permits text selection.
Check if vertical scroll is permitted.
A list of ancestor nodes found by tracing a path all the way back to App.
A list of ancestor nodes found by tracing a path all the way back to App.
Get the current app.
Number of seconds between automatic refresh, or None for no automatic refresh.
Background colors adjusted for opacity.
A title to show in the bottom border (if there is one).
A title to show in the top border (if there is one).
Widget may receive focus.
Widget's children may receive focus.
A view on to the children.
The widget's background and foreground colors, and the parent's background and foreground colors.
The scroll offset the nearest container ancestor.
The size of the container (parent widget).
The viewport region (parent window).
An offset from the Widget origin where the content begins.
Gets an absolute region containing the content (minus padding and border).
The size of the content area.
A CSS selector that identifies this DOM node.
A syntax highlighted CSS identifier.
A list of nodes from the App to this node, forming a "path".
A Rich tree to display the DOM, annotated with the node's CSS.
The currently selected node, or
Noneif no selection.Should the DOM node be displayed?
The displayed children (where node.display==True and node.visible==True).
The displayed children (where node.display==True).
Space allocated to docks in the parent.
Is this the first widget in its siblings?
Is this the first widget of its type in its siblings?
Can this widget currently be focused?
Spacing for padding / border / scrollbars.
Are any descendants focused?
Does this object have a parent?
The horizontal scrollbar.
The ID of this node, or None if the node has no ID.
Is this widget anchored?
Is this node linked to the app through the DOM?
Since a ScrollView should be a line-api widget, it won't have children, and therefore isn't a container.
Is the widget disabled either because disabled=True or an ancestor has disabled=True.
Is this a root node (i.e. the App)?.
Are there no displayed children?
Is this widget at an evenly numbered position within its siblings?
Is the horizontal scroll position at the maximum?
Is the user dragging the vertical scrollbar?
Is this widget, or a parent maximized?
Is this widget maximized?
Is the node a modal?
Check if this widget is mounted.
Is the mouse currently over this widget?
Is this widget at an oddly numbered position within its siblings?
Check if the node was displayed in the last screen update.
Is the parent active?
Is the message pump running (potentially processing messages)?
Always scrollable.
Is this widget currently scrolling?
Is the vertical scroll position at the maximum?
Is the user dragging the vertical scrollbar?
Is this the last widget in its siblings?
The index of the last line.
Is this the last widget of its type in its siblings?
Get the name of this widgets layer.
Layers of from parent.
Get the layout object if set in styles, or a default layout.
Style of links.
Style of links underneath the mouse cursor.
Get a logger for this object.
The maximum value of scroll_x.
The maximum value of scroll_y.
The current size of the message queue.
The name of the node.
Widget offset from origin.
Total opacity of widget.
The size of the widget (including padding and border).
The parent node.
A (frozen) set of all pseudo classes.
The region occupied by this widget, relative to the Screen.
Get a Rich Style object for this DOMNode.
The screen containing this node.
Get the current scroll offset.
Gets an absolute region containing the scrollable content (minus padding, border, and scrollbars).
The size of the scrollable content.
The scrollbar corner.
Spacing required to fit scrollbar(s).
Get the height used by the horizontal scrollbar.
Get the width used by the vertical scrollbar.
A tuple of booleans that indicate if scrollbars are enabled.
The number of cells occupied by scrollbars for width and height
The widget's container used when selecting text..
The style of selected text.
Get the widget's siblings (self is removed from the return list).
The size of the content area.
taskText selection information, or None if no text is selected in this widget.
Get the text style object.
Tooltip for the widget, or None for no tooltip.
A Rich tree to display the DOM.
The vertical scrollbar (create if necessary).
The widget region relative to its container (which may not be visible, depending on scroll offset).
The widget region relative to its container (including margin), which may not be visible, depending on the scroll offset.
Is this widget visible in the DOM?
A list of siblings which will be shown.
The widget's current style.
The region within the scrollable area that is currently visible.
The app's worker manager.
The root node of the tree.
Force an absolute offset for the widget (used by tooltips).
asyncio lock to be used to synchronize the state of the widget.
CSS class names for this node.
Subscribe to this signal to be notified of all messages sent to this widget.
- find_node_by_path(path)[source]
Return the first tree node whose stored path matches
path.- Return type:
TreeNode[SimulationNodeData] | None
- ALLOW_MAXIMIZE: ClassVar[bool | None] = True
Defines default logic to allow the widget to be maximized.
None Use default behavior (Focusable widgets may be maximized)
False Do not allow widget to be maximized
True Allow widget to be maximized
- ALLOW_SELECT: ClassVar[bool] = False
Does this widget support automatic text selection? May be further refined with [Widget.allow_select][textual.widget.Widget.allow_select].
- BINDING_GROUP_TITLE: str | None = None
Title of widget used where bindings are displayed (such as in the key panel).
- BLANK: ClassVar[bool] = False
Is this widget blank (no border, no content)? Enable for very large scrolling containers.
- BORDER_SUBTITLE: ClassVar[str] = ''
Initial value for border_subtitle attribute.
- BORDER_TITLE: ClassVar[str] = ''
Initial value for border_title attribute.
- COMPONENT_CLASSES: ClassVar[set[str]] = {'tree--cursor', 'tree--guides', 'tree--guides-hover', 'tree--guides-selected', 'tree--highlight', 'tree--highlight-line', 'tree--label'}
- Class | Description |:- | :- |tree–cursor | Targets the cursor. |tree–guides | Targets the indentation guides. |tree–guides-hover | Targets the indentation guides under the cursor. |tree–guides-selected | Targets the indentation guides that are selected. |tree–highlight | Targets the highlighted items. |tree–highlight-line | Targets the lines under the cursor. |tree–label | Targets the (text) labels of the items. |
- DEFAULT_CLASSES: ClassVar[str] = ''
Default classes argument if not supplied.
- DEFAULT_CSS: ClassVar[str] = '\n Tree {\n background: $surface;\n color: $foreground;\n\n & > .tree--label {}\n & > .tree--guides {\n color: $surface-lighten-2;\n }\n & > .tree--guides-hover {\n color: $surface-lighten-2;\n }\n & > .tree--guides-selected {\n color: $block-cursor-blurred-background;\n }\n & > .tree--cursor {\n text-style: $block-cursor-blurred-text-style;\n background: $block-cursor-blurred-background;\n }\n & > .tree--highlight {}\n & > .tree--highlight-line {\n background: $block-hover-background;\n }\n\n &:focus {\n background-tint: $foreground 5%;\n & > .tree--cursor {\n color: $block-cursor-foreground;\n background: $block-cursor-background;\n text-style: $block-cursor-text-style;\n }\n & > .tree--guides {\n color: $surface-lighten-3;\n }\n & > .tree--guides-hover {\n color: $surface-lighten-3;\n }\n & > .tree--guides-selected {\n color: $block-cursor-background;\n }\n }\n\n &:light {\n /* In light mode the guides are darker*/\n & > .tree--guides {\n color: $surface-darken-1;\n }\n & > .tree--guides-hover {\n color: $block-cursor-background;\n }\n & > .tree--guides-selected {\n color: $block-cursor-background;\n }\n }\n\n\n }\n Tree:ansi {\n color: ansi_default;\n & > .tree--guides {\n color: $ansi-background;\n }\n &:nocolor > .tree--cursor{\n text-style: reverse;\n } \n }\n \n '
Default TCSS.
- FOCUS_ON_CLICK: ClassVar[bool] = True
Should focusable widgets be automatically focused on click? Default return value of [Widget.focus_on_click][textual.widget.Widget.focus_on_click].
- HELP: ClassVar[str | None] = None
Optional help text shown in help panel (Markdown format).
- ICON_NODE = '▶ '
Unicode ‘icon’ to use for an expandable node.
- ICON_NODE_EXPANDED = '▼ '
Unicode ‘icon’ to use for an expanded node.
- SCOPED_CSS: ClassVar[bool] = True
Should default css be limited to the widget type?
- property allow_horizontal_scroll: bool
Check if horizontal scroll is permitted.
May be overridden if you want different logic regarding allowing scrolling.
- property allow_maximize: bool
Check if the widget may be maximized.
- Returns:
True if the widget may be maximized, or False if it should not be maximized.
- property allow_select: bool
Check if this widget permits text selection.
- Returns:
True if the widget supports text selection, otherwise False.
- property allow_vertical_scroll: bool
Check if vertical scroll is permitted.
May be overridden if you want different logic regarding allowing scrolling.
- property ancestors: list[DOMNode]
A list of ancestor nodes found by tracing a path all the way back to App.
- Returns:
A list of nodes.
- property ancestors_with_self: list[DOMNode]
A list of ancestor nodes found by tracing a path all the way back to App.
- Note:
This is inclusive of
self.- Returns:
A list of nodes.
- property app: App[object]
Get the current app.
- Returns:
The current app.
- Raises:
NoActiveAppError: if no active app could be found for the current asyncio context
- property auto_refresh: float | None
Number of seconds between automatic refresh, or None for no automatic refresh.
- property background_colors: tuple[Color, Color]
Background colors adjusted for opacity.
- Returns:
(<background color>, <color>)
- border_subtitle = None
A title to show in the bottom border (if there is one).
- border_title = None
A title to show in the top border (if there is one).
- can_focus: bool = True
Widget may receive focus.
- can_focus_children: bool = True
Widget’s children may receive focus.
- property children: Sequence['Widget']
A view on to the children.
- Returns:
The node’s children.
- property colors: tuple[Color, Color, Color, Color]
The widget’s background and foreground colors, and the parent’s background and foreground colors.
- Returns:
(<parent background>, <parent color>, <background>, <color>)
- property container_scroll_offset: Offset
The scroll offset the nearest container ancestor.
- property container_size: Size
The size of the container (parent widget).
- Returns:
Container size.
- property container_viewport: Region
The viewport region (parent window).
- Returns:
The region that contains this widget.
- property content_offset: Offset
An offset from the Widget origin where the content begins.
- Returns:
Offset from widget’s origin.
- property content_region: Region
Gets an absolute region containing the content (minus padding and border).
- Returns:
Screen region that contains a widget’s content.
- property content_size: Size
The size of the content area.
- Returns:
Content area size.
- property css_identifier: str
A CSS selector that identifies this DOM node.
- property css_identifier_styled: Text
A syntax highlighted CSS identifier.
- Returns:
A Rich Text object.
- property css_path_nodes: list[DOMNode]
A list of nodes from the App to this node, forming a “path”.
- Returns:
A list of nodes, where the first item is the App, and the last is this node.
- property css_tree: Tree
A Rich tree to display the DOM, annotated with the node’s CSS.
Log this to visualize your app in the textual console.
- Example:
`python self.log(self.css_tree) `- Returns:
A Tree renderable.
- property cursor_node: TreeNode[TreeDataType] | None
The currently selected node, or
Noneif no selection.
- property display: bool
Should the DOM node be displayed?
May be set to a boolean to show or hide the node, or to any valid value for the display rule.
- Example:
`python my_widget.display = False # Hide my_widget `
- property displayed_and_visible_children: Sequence[Widget]
The displayed children (where node.display==True and node.visible==True).
- Returns:
A sequence of widgets.
- property displayed_children: Sequence[Widget]
The displayed children (where node.display==True).
- Returns:
A sequence of widgets.
- property dock_gutter: Spacing
Space allocated to docks in the parent.
- Returns:
Space to be subtracted from scrollable area.
- property first_child: bool
Is this the first widget in its siblings?
- property first_of_type: bool
Is this the first widget of its type in its siblings?
- property focusable: bool
Can this widget currently be focused?
- property gutter: Spacing
Spacing for padding / border / scrollbars.
- Returns:
Additional spacing around content area.
- property has_focus_within: bool
Are any descendants focused?
- property has_parent: bool
Does this object have a parent?
- property horizontal_scrollbar: ScrollBar
The horizontal scrollbar.
- Note:
This will create a scrollbar if one doesn’t exist.
- Returns:
ScrollBar Widget.
- property id: str | None
The ID of this node, or None if the node has no ID.
- property is_anchored: bool
Is this widget anchored?
See [anchor()][textual.widget.Widget.anchor] for an explanation of anchoring.
- property is_attached: bool
Is this node linked to the app through the DOM?
- property is_container: bool
Since a ScrollView should be a line-api widget, it won’t have children, and therefore isn’t a container.
- property is_disabled: bool
Is the widget disabled either because disabled=True or an ancestor has disabled=True.
- property is_dom_root
Is this a root node (i.e. the App)?
- property is_empty: bool
Are there no displayed children?
- property is_even: bool
Is this widget at an evenly numbered position within its siblings?
- property is_horizontal_scroll_end: bool
Is the horizontal scroll position at the maximum?
- property is_horizontal_scrollbar_grabbed: bool
Is the user dragging the vertical scrollbar?
- property is_in_maximized_view: bool
Is this widget, or a parent maximized?
- property is_maximized: bool
Is this widget maximized?
- property is_modal: bool
Is the node a modal?
- property is_mounted: bool
Check if this widget is mounted.
- property is_mouse_over: bool
Is the mouse currently over this widget?
Note this will be True if the mouse pointer is within the widget’s region, even if the mouse pointer is not directly over the widget (there could be another widget between the mouse pointer and self).
- property is_odd: bool
Is this widget at an oddly numbered position within its siblings?
- property is_on_screen: bool
Check if the node was displayed in the last screen update.
- property is_parent_active: bool
Is the parent active?
- property is_running: bool
Is the message pump running (potentially processing messages)?
- property is_scrollable: bool
Always scrollable.
- property is_scrolling: bool
Is this widget currently scrolling?
- property is_vertical_scroll_end: bool
Is the vertical scroll position at the maximum?
- property is_vertical_scrollbar_grabbed: bool
Is the user dragging the vertical scrollbar?
- property last_child: bool
Is this the last widget in its siblings?
- property last_line: int
The index of the last line.
- property last_of_type: bool
Is this the last widget of its type in its siblings?
- property layer: str
Get the name of this widgets layer.
- Returns:
Name of layer.
- property layers: tuple[str, ...]
Layers of from parent.
- Returns:
Tuple of layer names.
- property layout: Layout
Get the layout object if set in styles, or a default layout.
- Returns:
A layout object.
- property link_style: Style
Style of links.
- Returns:
Rich style.
- property link_style_hover: Style
Style of links underneath the mouse cursor.
- Returns:
Rich Style.
- property log: Logger
Get a logger for this object.
- Returns:
A logger.
- property max_scroll_x: int
The maximum value of scroll_x.
- property max_scroll_y: int
The maximum value of scroll_y.
- property message_queue_size: int
The current size of the message queue.
- property name: str | None
The name of the node.
- property offset: Offset
Widget offset from origin.
- Returns:
Relative offset.
- property opacity: float
Total opacity of widget.
- property outer_size: Size
The size of the widget (including padding and border).
- Returns:
Outer size.
- property parent: DOMNode | None
The parent node.
All nodes have parent once added to the DOM, with the exception of the App which is the root node.
- property pseudo_classes: frozenset[str]
A (frozen) set of all pseudo classes.
- property region: Region
The region occupied by this widget, relative to the Screen.
- Returns:
Region within screen occupied by widget.
- property rich_style: Style
Get a Rich Style object for this DOMNode.
- Returns:
A Rich style.
- property screen: Screen[object]
The screen containing this node.
- Returns:
A screen object.
- Raises:
NoScreen: If this node isn’t mounted (and has no screen).
- property scroll_offset: Offset
Get the current scroll offset.
- Returns:
Offset a container has been scrolled by.
- property scrollable_content_region: Region
Gets an absolute region containing the scrollable content (minus padding, border, and scrollbars).
- Returns:
Screen region that contains a widget’s content.
- property scrollable_size: Size
The size of the scrollable content.
- Returns:
Scrollable content size.
- property scrollbar_corner: ScrollBarCorner
The scrollbar corner.
- Note:
This will create a scrollbar corner if one doesn’t exist.
- Returns:
ScrollBarCorner Widget.
- property scrollbar_gutter: Spacing
Spacing required to fit scrollbar(s).
- Returns:
Scrollbar gutter spacing.
- property scrollbar_size_horizontal: int
Get the height used by the horizontal scrollbar.
- Returns:
Number of rows in the horizontal scrollbar.
- property scrollbar_size_vertical: int
Get the width used by the vertical scrollbar.
- Returns:
Number of columns in the vertical scrollbar.
- property scrollbars_enabled: tuple[bool, bool]
A tuple of booleans that indicate if scrollbars are enabled.
- Returns:
A tuple of (<vertical scrollbar enabled>, <horizontal scrollbar enabled>)
- property scrollbars_space: tuple[int, int]
The number of cells occupied by scrollbars for width and height
- property select_container: Widget
The widget’s container used when selecting text..
- Returns:
A widget which contains this widget.
- property selection_style: Style
The style of selected text.
- property siblings: list[Widget]
Get the widget’s siblings (self is removed from the return list).
- Returns:
A list of siblings.
- property size: Size
The size of the content area.
- Returns:
Content area size.
- property text_selection: Selection | None
Text selection information, or None if no text is selected in this widget.
- property text_style: Style
Get the text style object.
A widget’s style is influenced by its parent. for instance if a parent is bold, then the child will also be bold.
- Returns:
A Rich Style.
- property tooltip: VisualType | None
Tooltip for the widget, or None for no tooltip.
- property tree: Tree
A Rich tree to display the DOM.
Log this to visualize your app in the textual console.
- Example:
`python self.log(self.tree) `- Returns:
A Tree renderable.
- property vertical_scrollbar: ScrollBar
The vertical scrollbar (create if necessary).
- Note:
This will create a scrollbar if one doesn’t exist.
- Returns:
ScrollBar Widget.
- property virtual_region: Region
The widget region relative to its container (which may not be visible, depending on scroll offset).
- Returns:
The virtual region.
- property virtual_region_with_margin: Region
The widget region relative to its container (including margin), which may not be visible, depending on the scroll offset.
- Returns:
The virtual region of the Widget, inclusive of its margin.
- property visible: bool
Is this widget visible in the DOM?
If a widget hasn’t had its visibility set explicitly, then it inherits it from its DOM ancestors.
This may be set explicitly to override inherited values. The valid values include the valid values for the visibility rule and the booleans True or False, to set the widget to be visible or invisible, respectively.
When a node is invisible, Textual will reserve space for it, but won’t display anything.
- property visible_siblings: list[Widget]
A list of siblings which will be shown.
- Returns:
List of siblings.
- property visual_style: Style
The widget’s current style.
- property window_region: Region
The region within the scrollable area that is currently visible.
- Returns:
New region.
- property workers: WorkerManager
The app’s worker manager. Shortcut for self.app.workers.
- root
The root node of the tree.
- absolute_offset: Offset | None
Force an absolute offset for the widget (used by tooltips).
- lock
asyncio lock to be used to synchronize the state of the widget.
Two different tasks might call methods on a widget at the same time, which might result in a race condition. This can be fixed by adding async with widget.lock: around the method calls.
- classes
CSS class names for this node.
- message_signal: Signal[Message]
Subscribe to this signal to be notified of all messages sent to this widget.
This is a fairly low-level mechanism, and shouldn’t replace regular message handling.