buffalo_panel.app.tui.Panel2dTUI

class buffalo_panel.app.tui.Panel2dTUI(filename=None, read_only=False, **kwargs)[source]

Bases: App[None]

TUI for browsing and editing Buffalo Panel simulations.

Methods

compose()

Create child widgets for the app.

on_input_submitted(event)

Apply one typed text edit from the input widget.

on_mount()

Initialize the tree with default simulation data on startup.

on_select_changed(event)

Apply one choice-based edit from the select widget.

on_tree_node_highlighted(event)

Update the details pane when a node is highlighted.

on_tree_node_selected(event)

Focus the active editor when one editable leaf is selected.

refresh_tree([cursor_path])

Rebuild the configuration tree from current data.

Attributes

ALLOW_IN_MAXIMIZED_VIEW

The default value of [Screen.ALLOW_IN_MAXIMIZED_VIEW][textual.screen.Screen.ALLOW_IN_MAXIMIZED_VIEW].

ALLOW_SELECT

A switch to toggle arbitrary text selection for the app.

AUTO_FOCUS

A selector to determine what to focus automatically when a screen is activated.

BINDING_GROUP_TITLE

Set to text to show in the key panel.

CLICK_CHAIN_TIME_THRESHOLD

The maximum number of seconds between clicks to upgrade a single click to a double click, a double click to a triple click, etc.

CLOSE_TIMEOUT

Timeout waiting for widget's to close, or None for no timeout.

COMMAND_PALETTE_BINDING

The key that launches the command palette (if enabled by [App.ENABLE_COMMAND_PALETTE][textual.app.App.ENABLE_COMMAND_PALETTE]).

COMMAND_PALETTE_DISPLAY

How the command palette key should be displayed in the footer (or None for default).

COMPONENT_CLASSES

Virtual DOM nodes, used to expose styles to line API widgets.

CSS_PATH

File paths to load CSS from.

DEFAULT_CLASSES

Default classes argument if not supplied.

DEFAULT_CSS

Default TCSS.

DEFAULT_MODE

Name of the default mode.

ENABLE_COMMAND_PALETTE

Should the [command palette][textual.command.CommandPalette] be enabled for the application?

ENABLE_SELECT_AUTO_SCROLL

Enable automatic scrolling if selecting and the mouse is at the top or bottom of the widget?

ESCAPE_TO_MINIMIZE

Use escape key to minimize widgets (potentially overriding bindings).

HELP

Optional help text shown in help panel (Markdown format).

INLINE_PADDING

Number of blank lines above an inline app.

NOTIFICATION_TIMEOUT

Default number of seconds to show notifications before removing them.

PAUSE_GC_ON_SCROLL

Pause Python GC (Garbage Collection) when scrolling, for potentially smoother scrolling with many widgets (experimental).

SCOPED_CSS

Should default css be limited to the widget type?

SELECT_AUTO_SCROLL_LINES

Number of lines in auto-scrolling regions at the top and bottom of a widget.

SELECT_AUTO_SCROLL_SPEED

Maximum speed of select auto-scroll in lines per second.

SUB_TITLE

A class variable to set the default sub-title for the application.

SUSPENDED_SCREEN_CLASS

Class to apply to suspended screens, or empty string for no class.

TITLE

A class variable to set the default title for the application.

TOOLTIP_DELAY

The time in seconds after which a tooltip gets displayed.

active_bindings

Get currently active bindings.

ancestors

A list of ancestor nodes found by tracing a path all the way back to App.

ancestors_with_self

A list of ancestor nodes found by tracing a path all the way back to App.

animator

The animator object.

ansi_theme

The ANSI TerminalTheme currently being used.

app

Get the current app.

auto_refresh

Number of seconds between automatic refresh, or None for no automatic refresh.

available_themes

All available themes (all built-in themes plus any that have been registered).

background_colors

Background colors adjusted for opacity.

children

A view onto the app's immediate children.

clipboard

The value of the local clipboard.

colors

The widget's background and foreground colors, and the parent's background and foreground colors.

console_options

Get options for the Rich console.

css_identifier

A CSS selector that identifies this DOM node.

css_identifier_styled

A syntax highlighted CSS identifier.

css_path_nodes

A list of nodes from the App to this node, forming a "path".

css_tree

A Rich tree to display the DOM, annotated with the node's CSS.

current_mode

The name of the currently active mode.

current_theme

debug

Is debug mode enabled?

default_screen

The default screen instance.

display

Should the DOM node be displayed?

displayed_and_visible_children

The displayed children (where node.display==True and node.visible==True).

displayed_children

The displayed children (where node.display==True).

escape_to_minimize

Use the escape key to minimize?

focused

The widget that is focused on the currently active screen, or None.

has_parent

Does this object have a parent?

id

The ID of this node, or None if the node has no ID.

is_attached

Is this node linked to the app through the DOM?

is_dom_root

Is this a root node (i.e. the App)?.

is_empty

Are there no displayed children?

is_headless

Is the app running in 'headless' mode?

is_inline

Is the app running in 'inline' mode?

is_modal

Is the node a modal?

is_on_screen

Check if the node was displayed in the last screen update.

is_parent_active

Is the parent active?

is_running

Is the message pump running (potentially processing messages)?

is_web

Is the app running in 'web' mode via a browser?

log

The textual logger.

message_queue_size

The current size of the message queue.

name

The name of the node.

native_ansi_color

Use native ANSI colors?

parent

The parent node.

pseudo_classes

A (frozen) set of all pseudo classes.

return_code

The return code with which the app exited.

return_value

The return value of the app, or None if it has not yet been set.

rich_style

Get a Rich Style object for this DOMNode.

screen

The current active screen.

screen_stack

A snapshot of the current screen stack.

selection_style

The style of selected text.

simulation_tree

Return the simulation tree widget.

size

The size of the terminal.

task

text_style

Get the text style object.

tree

A Rich tree to display the DOM.

value_select

Return the scalar-choice widget.

viewport_size

Get the viewport size (size of the screen).

visible

Is this widget visible in the DOM?

workers

The [worker](/guide/workers/) manager.

mouse_over

The widget directly under the mouse.

hover_over

The first widget with a hover style under the mouse.

mouse_position

The current screen-space mouse position.

mouse_position_high_resolution

A high resolution (floating point) mouse position.

cursor_position

The position of the terminal cursor in screen-space.

use_command_palette

A flag to say if the application should use the command palette.

theme_variables

Variables generated from the current theme.

scroll_sensitivity_x

Number of columns to scroll in the X direction with wheel or trackpad.

scroll_sensitivity_y

Number of lines to scroll in the Y direction with wheel or trackpad.

theme_changed_signal

Signal that is published when the App's theme is changed.

app_suspend_signal

The signal that is published when the app is suspended.

app_resume_signal

The signal that is published when the app is resumed after a suspend.

mode_change_signal

A signal published when the current screen mode changes.

screen_change_signal

A signal published when the current screen changes.

animation_level

Determines what type of animations the app will display.

supports_smooth_scrolling

Does the terminal support smooth scrolling?

classes

CSS class names for this node.

message_signal

Subscribe to this signal to be notified of all messages sent to this widget.

TITLE: str | None = 'Buffalo Panel Case Explorer'

A class variable to set the default title for the application.

To update the title while the app is running, you can set the [title][textual.app.App.title] attribute. See also [the Screen.TITLE attribute][textual.screen.Screen.TITLE].

property simulation_tree: Tree[SimulationNodeData]

Return the simulation tree widget.

property value_select: Select[SimulationScalar]

Return the scalar-choice widget.

compose()[source]

Create child widgets for the app.

Return type:

Iterable[Widget]

on_mount()[source]

Initialize the tree with default simulation data on startup.

refresh_tree(cursor_path=None)[source]

Rebuild the configuration tree from current data.

on_tree_node_highlighted(event)[source]

Update the details pane when a node is highlighted.

on_tree_node_selected(event)[source]

Focus the active editor when one editable leaf is selected.

on_input_submitted(event)[source]

Apply one typed text edit from the input widget.

on_select_changed(event)[source]

Apply one choice-based edit from the select widget.

ALLOW_IN_MAXIMIZED_VIEW: ClassVar[str] = 'Footer'

The default value of [Screen.ALLOW_IN_MAXIMIZED_VIEW][textual.screen.Screen.ALLOW_IN_MAXIMIZED_VIEW].

ALLOW_SELECT: ClassVar[bool] = True

A switch to toggle arbitrary text selection for the app.

Note that this doesn’t apply to Input and TextArea which have builtin support for selection.

AUTO_FOCUS: ClassVar[str | None] = '*'

A selector to determine what to focus automatically when a screen is activated.

The widget focused is the first that matches the given [CSS selector](/guide/queries/#query-selectors). Setting to None or “” disables auto focus.

BINDING_GROUP_TITLE: str | None = None

Set to text to show in the key panel.

CLICK_CHAIN_TIME_THRESHOLD: ClassVar[float] = 0.5

The maximum number of seconds between clicks to upgrade a single click to a double click, a double click to a triple click, etc.

CLOSE_TIMEOUT: float | None = 5.0

Timeout waiting for widget’s to close, or None for no timeout.

COMMAND_PALETTE_BINDING: ClassVar[str] = 'ctrl+p'

The key that launches the command palette (if enabled by [App.ENABLE_COMMAND_PALETTE][textual.app.App.ENABLE_COMMAND_PALETTE]).

COMMAND_PALETTE_DISPLAY: ClassVar[str | None] = None

How the command palette key should be displayed in the footer (or None for default).

COMPONENT_CLASSES: ClassVar[set[str]] = {}

Virtual DOM nodes, used to expose styles to line API widgets.

CSS_PATH: ClassVar[CSSPathType | None] = None

File paths to load CSS from.

DEFAULT_CLASSES: ClassVar[str] = ''

Default classes argument if not supplied.

DEFAULT_CSS: ClassVar[str] = '\n    App {\n        background: $background;\n        color: $foreground;\n\n        &:ansi {\n            background: ansi_default;\n            color: ansi_default;\n\n            .-ansi-scrollbar {\n                scrollbar-background: ansi_default;\n                scrollbar-background-hover: ansi_default;\n                scrollbar-background-active: ansi_default;\n                scrollbar-color: ansi_blue;\n                scrollbar-color-active: ansi_bright_blue;\n                scrollbar-color-hover: ansi_bright_blue;    \n                scrollbar-corner-color: ansi_default;           \n            }\n\n            .bindings-table--key {\n                color: ansi_magenta;\n            }\n            .bindings-table--description {\n                color: ansi_default;\n            }\n\n            .bindings-table--header {\n                color: ansi_default;\n            }\n\n            .bindings-table--divider {\n                color: transparent;\n                text-style: dim;\n            }\n        }\n\n        /* When a widget is maximized */\n        Screen.-maximized-view {                    \n            layout: vertical !important;\n            hatch: right $panel;\n            overflow-y: auto !important;\n            align: center middle;\n            .-maximized {\n                dock: initial !important;                \n            }\n        }\n        /* Fade the header title when app is blurred */\n        &:blur HeaderTitle {           \n            text-opacity: 50%;           \n        }\n    }\n    *:disabled:can-focus {\n        opacity: 0.7;\n    }\n    '

Default TCSS.

DEFAULT_MODE: ClassVar[str] = '_default'

Name of the default mode.

ENABLE_COMMAND_PALETTE: ClassVar[bool] = True

Should the [command palette][textual.command.CommandPalette] be enabled for the application?

ENABLE_SELECT_AUTO_SCROLL: ClassVar[bool] = True

Enable automatic scrolling if selecting and the mouse is at the top or bottom of the widget?

ESCAPE_TO_MINIMIZE: ClassVar[bool] = True

Use escape key to minimize widgets (potentially overriding bindings).

This is the default value, used if the active screen’s ESCAPE_TO_MINIMIZE is not changed from None.

HELP: ClassVar[str | None] = None

Optional help text shown in help panel (Markdown format).

INLINE_PADDING: ClassVar[int] = 1

Number of blank lines above an inline app.

NOTIFICATION_TIMEOUT: ClassVar[float] = 5

Default number of seconds to show notifications before removing them.

PAUSE_GC_ON_SCROLL: ClassVar[bool] = False

Pause Python GC (Garbage Collection) when scrolling, for potentially smoother scrolling with many widgets (experimental).

SCOPED_CSS: ClassVar[bool] = True

Should default css be limited to the widget type?

SELECT_AUTO_SCROLL_LINES: ClassVar[int] = 3

Number of lines in auto-scrolling regions at the top and bottom of a widget.

SELECT_AUTO_SCROLL_SPEED: ClassVar[float] = 60.0

Maximum speed of select auto-scroll in lines per second.

SUB_TITLE: str | None = None

A class variable to set the default sub-title for the application.

To update the sub-title while the app is running, you can set the [sub_title][textual.app.App.sub_title] attribute. See also [the Screen.SUB_TITLE attribute][textual.screen.Screen.SUB_TITLE].

SUSPENDED_SCREEN_CLASS: ClassVar[str] = ''

Class to apply to suspended screens, or empty string for no class.

TOOLTIP_DELAY: float = 0.5

The time in seconds after which a tooltip gets displayed.

property active_bindings: dict[str, ActiveBinding]

Get currently active bindings.

If no widget is focused, then app-level bindings are returned. If a widget is focused, then any bindings present in the active screen and app are merged and returned.

This property may be used to inspect current bindings.

Returns:

A dict that maps keys on to binding information.

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 animator: Animator

The animator object.

property ansi_theme: TerminalTheme

The ANSI TerminalTheme currently being used.

Defines how colors defined as ANSI (e.g. magenta) inside Rich renderables are mapped to hex codes.

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 available_themes: dict[str, Theme]

All available themes (all built-in themes plus any that have been registered).

A dictionary mapping theme names to Theme instances.

property background_colors: tuple[Color, Color]

Background colors adjusted for opacity.

Returns:

(<background color>, <color>)

property children: Sequence[Widget]

A view onto the app’s immediate children.

This attribute exists on all widgets. In the case of the App, it will only ever contain a single child, which will be the currently active screen.

Returns:

A sequence of widgets.

property clipboard: str

The value of the local clipboard.

Note, that this only contains text copied in the app, and not text copied from elsewhere in the OS.

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 console_options: ConsoleOptions

Get options for the Rich console.

Returns:

Console options (same object returned from console.options).

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 current_mode: str

The name of the currently active mode.

property debug: bool

Is debug mode enabled?

property default_screen: Screen

The default screen instance.

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 escape_to_minimize: bool

Use the escape key to minimize?

When a widget is [maximized][textual.screen.Screen.maximize], this boolean determines if the escape key will minimize the widget (potentially overriding any bindings).

The default logic is to use the screen’s ESCAPE_TO_MINIMIZE classvar if it is set to True or False. If the classvar on the screen is not set (and left as None), then the app’s ESCAPE_TO_MINIMIZE is used.

property focused: Widget | None

The widget that is focused on the currently active screen, or None.

Focused widgets receive keyboard input.

Returns:

The currently focused widget, or None if nothing is focused.

property has_parent: bool

Does this object have a parent?

property id: str | None

The ID of this node, or None if the node has no ID.

property is_attached: bool

Is this node linked to the app through the DOM?

property is_dom_root: bool

Is this a root node (i.e. the App)?

property is_empty: bool

Are there no displayed children?

property is_headless: bool

Is the app running in ‘headless’ mode?

Headless mode is used when running tests with [run_test][textual.app.App.run_test].

property is_inline: bool

Is the app running in ‘inline’ mode?

property is_modal: bool

Is the node a modal?

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_web: bool

Is the app running in ‘web’ mode via a browser?

property log: Logger

The textual logger.

Example:

`python self.log("Hello, World!") self.log(self.tree) `

Returns:

A Textual logger.

property message_queue_size: int

The current size of the message queue.

property name: str | None

The name of the node.

property native_ansi_color: bool

Use native ANSI colors?

This will return self.current_theme.ansi if self.ansi_color is None, otherwise it will return self.ansi_color.

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 return_code: int | None

The return code with which the app exited.

Non-zero codes indicate errors. A value of 1 means the app exited with a fatal error. If the app hasn’t exited yet, this will be None.

Example:

The return code can be used to exit the process via sys.exit. `py my_app.run() sys.exit(my_app.return_code) `

property return_value: ReturnType | None

The return value of the app, or None if it has not yet been set.

The return value is set when calling [exit][textual.app.App.exit].

property rich_style: Style

Get a Rich Style object for this DOMNode.

Returns:

A Rich style.

property screen: Screen[object]

The current active screen.

Returns:

The currently active (visible) screen.

Raises:

ScreenStackError: If there are no screens on the stack.

property screen_stack: list[Screen[Any]]

A snapshot of the current screen stack.

Returns:

A snapshot of the current state of the screen stack.

property selection_style: Style

The style of selected text.

property size: Size

The size of the terminal.

Returns:

Size of the terminal.

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 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 viewport_size: Size

Get the viewport size (size of the screen).

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 workers: WorkerManager

The [worker](/guide/workers/) manager.

Returns:

An object to manage workers.

mouse_over: Widget | None

The widget directly under the mouse.

hover_over: Widget | None

The first widget with a hover style under the mouse.

mouse_position

The current screen-space mouse position.

mouse_position_high_resolution: tuple[float, float]

A high resolution (floating point) mouse position. If supported by the terminal, this may be more granular than mouse_position

cursor_position

The position of the terminal cursor in screen-space.

This can be set by widgets and is useful for controlling the positioning of OS IME and emoji popup menus.

use_command_palette: bool

A flag to say if the application should use the command palette.

If set to False any call to [action_command_palette][textual.app.App.action_command_palette] will be ignored.

theme_variables: dict[str, str]

Variables generated from the current theme.

scroll_sensitivity_x: float

Number of columns to scroll in the X direction with wheel or trackpad.

scroll_sensitivity_y: float

Number of lines to scroll in the Y direction with wheel or trackpad.

theme_changed_signal: Signal[Theme]

Signal that is published when the App’s theme is changed.

Subscribers will receive the new theme object as an argument to the callback.

app_suspend_signal: Signal[App]

The signal that is published when the app is suspended.

When [App.suspend][textual.app.App.suspend] is called this signal will be [published][textual.signal.Signal.publish]; [subscribe][textual.signal.Signal.subscribe] to this signal to perform work before the suspension takes place.

app_resume_signal: Signal[App]

The signal that is published when the app is resumed after a suspend.

When the app is resumed after a [App.suspend][textual.app.App.suspend] call this signal will be [published][textual.signal.Signal.publish]; [subscribe][textual.signal.Signal.subscribe] to this signal to perform work after the app has resumed.

mode_change_signal: Signal[str]

A signal published when the current screen mode changes.

screen_change_signal: Signal[Screen]

A signal published when the current screen changes.

animation_level: AnimationLevel

Determines what type of animations the app will display.

See [textual.constants.TEXTUAL_ANIMATIONS][textual.constants.TEXTUAL_ANIMATIONS].

supports_smooth_scrolling: bool

Does the terminal support smooth scrolling?

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.