conntextual.ui package

Contents

conntextual.ui package#

Subpackages#

Submodules#

conntextual.ui.base module#

A module implementing a user interface base application.

class conntextual.ui.base.Base(driver_class: Type[Driver] | None = None, css_path: str | PurePath | List[str | PurePath] | None = None, watch_css: bool = False, ansi_color: bool | None = None)[source]#

Bases: App[None]

A simple textual application.

BINDINGS = [('q', 'quit'), (Keys.Escape, 'quit', '(or q) quit'), ('space', 'toggle_pause', 'toggle pause'), ('d', 'toggle_dark', 'toggle dark mode'), ('g', 'screenshot', 'take a screenshot'), ('r', 'refresh_plot', 'refresh plot'), ('R', 'random_channel', 'plot random channel'), Binding(key=<Keys.Tab: 'tab'>, action='tab(True)', description='Next tab', show=True, key_display=None, priority=True, tooltip='', id=None, system=False, group=None), Binding(key=<Keys.BackTab: 'shift+tab'>, action='tab(False)', description='Previous tab', show=True, key_display=None, priority=True, tooltip='', id=None, system=False, group=None)]#

The default key bindings.

CSS_PATH = PosixPath('/home/runner/work/conntextual/conntextual/conntextual/data/tcss/base.tcss')#

File paths to load CSS from.

async action_quit() None[source]#

Stop the rest of the application when quitting.

action_random_channel() None[source]#

Randomize the channel on the current tab.

action_refresh_plot() None[source]#

Refresh the current plot.

action_tab(forward: bool) None[source]#

Change the active tab.

action_toggle_pause() None[source]#

Toggle pause state.

compose() Iterable[Widget][source]#

Create child nodes.

compose_app() Iterable[Widget][source]#

Application-specific interface creation.

composed: Event#
static create(app: AppInfo, env: ChannelEnvironment, handle_debug: bool = True) Base[source]#

Create an application instance.

property current_channel_environment: ChannelEnvironmentDisplay | None#

Get the current channel-environment display.

dispatch(max_plot_samples: int, update_table: bool = True, update_log: bool = True, update_plot: bool = True) None[source]#

Update channel values.

model: Model#
tab_pattern: PatternPair#
property tabs: TabbedContent#

Get the tab container.

ui_enabled(name: str) bool[source]#

Determine if a task tab should be created for a task with a given name.

conntextual.ui.footer module#

A module implementing a custom footer widget.

class conntextual.ui.footer.CustomFooter(*children: Widget, name: str | None = None, id: str | None = None, classes: str | None = None, disabled: bool = False, show_command_palette: bool = True, compact: bool = False)[source]#

Bases: Footer

An extension of the footer widget.

can_focus = False#

Widget may receive focus.

can_focus_children = False#

Widget’s children may receive focus.

current_tab: str | None#
render() ConsoleRenderable | RichCast | str[source]#

Render the footer.

conntextual.ui.model module#

A module implementing a data model for base applications.

class conntextual.ui.model.Model(app: AppInfo, env: ChannelEnvironment, environments: List[ChannelEnvironmentDisplay], uptime: DoublePrimitive, paused: BooleanPrimitive, start: float, tab_to_id: dict[str, str])[source]#

Bases: ChannelEnvironmentMixin

A base application model.

app: AppInfo#
static create(app: AppInfo, env: ChannelEnvironment) Model[source]#

Create a model instance.

env: ChannelEnvironment#
environments: List[ChannelEnvironmentDisplay]#
paused: BooleanPrimitive#
start: float#
tab_to_id: dict[str, str]#
uptime: DoublePrimitive#

conntextual.ui.task module#

A module implementing a TUI application task.

class conntextual.ui.task.TuiDispatch[source]#

Bases: TaskFactory[TuiDispatchTask]

A factory for the TUI dispatch task.

kind#

alias of TuiDispatchTask

class conntextual.ui.task.TuiDispatchTask(name: str, average_depth: int = 10, metrics: PeriodicTaskMetrics = None, period_s: float = 1.0, env: ChannelEnvironment = None, period_controls: dict[str, int | float | bool | dict[str, int | float | bool]] | str = 'period', markdown: str = None, config: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] = None)[source]#

Bases: ArbiterTask

A class implementing a periodic task for a textual TUI.

async dispatch() bool[source]#

Dispatch an iteration of this task.

async init(app: AppInfo) None[source]#

Initialize this task with application information.

poll_housekeeping() None[source]#

Update housekeeping metrics.

process: Process#
async stop_extra() None[source]#

Extra actions to perform when this task is stopping.

tui: Base#
tui_task: Task[None]#

Module contents#

A module implementing a basic user interface.

class conntextual.ui.Base(driver_class: Type[Driver] | None = None, css_path: str | PurePath | List[str | PurePath] | None = None, watch_css: bool = False, ansi_color: bool | None = None)[source]#

Bases: App[None]

A simple textual application.

BINDINGS = [('q', 'quit'), (Keys.Escape, 'quit', '(or q) quit'), ('space', 'toggle_pause', 'toggle pause'), ('d', 'toggle_dark', 'toggle dark mode'), ('g', 'screenshot', 'take a screenshot'), ('r', 'refresh_plot', 'refresh plot'), ('R', 'random_channel', 'plot random channel'), Binding(key=<Keys.Tab: 'tab'>, action='tab(True)', description='Next tab', show=True, key_display=None, priority=True, tooltip='', id=None, system=False, group=None), Binding(key=<Keys.BackTab: 'shift+tab'>, action='tab(False)', description='Previous tab', show=True, key_display=None, priority=True, tooltip='', id=None, system=False, group=None)]#

The default key bindings.

CSS_PATH = PosixPath('/home/runner/work/conntextual/conntextual/conntextual/data/tcss/base.tcss')#

File paths to load CSS from.

async action_quit() None[source]#

Stop the rest of the application when quitting.

action_random_channel() None[source]#

Randomize the channel on the current tab.

action_refresh_plot() None[source]#

Refresh the current plot.

action_tab(forward: bool) None[source]#

Change the active tab.

action_toggle_pause() None[source]#

Toggle pause state.

compose() Iterable[Widget][source]#

Create child nodes.

compose_app() Iterable[Widget][source]#

Application-specific interface creation.

composed: Event#
static create(app: AppInfo, env: ChannelEnvironment, handle_debug: bool = True) Base[source]#

Create an application instance.

property current_channel_environment: ChannelEnvironmentDisplay | None#

Get the current channel-environment display.

dispatch(max_plot_samples: int, update_table: bool = True, update_log: bool = True, update_plot: bool = True) None[source]#

Update channel values.

model: Model#
tab_pattern: PatternPair#
property tabs: TabbedContent#

Get the tab container.

ui_enabled(name: str) bool[source]#

Determine if a task tab should be created for a task with a given name.

class conntextual.ui.ChannelEnvironmentDisplay(content: VisualType = '', *, expand: bool = False, shrink: bool = False, markup: bool = True, name: str | None = None, id: str | None = None, classes: str | None = None, disabled: bool = False)[source]#

Bases: Static

A channel-environment interface element.

add_channel(name: str, chan: Channel[Int8Primitive] | Channel[Int16Primitive] | Channel[Int32Primitive] | Channel[Int64Primitive] | Channel[Uint8Primitive] | Channel[Uint16Primitive] | Channel[Uint32Primitive] | Channel[Uint64Primitive] | Channel[FloatPrimitive] | Channel[DoublePrimitive] | Channel[BooleanPrimitive], enum: RuntimeEnum | None) int[source]#

Add a channel to the table.

add_field(name: str) None[source]#

Add a bit-field row entry.

by_index: List[Tuple[Coordinate, str | int]]#
can_focus = False#

Widget may receive focus.

can_focus_children = True#

Widget’s children may receive focus.

channel_pattern: PatternPair#
channels_by_row: Dict[int, SelectedChannel]#
compose() Iterable[Widget][source]#

Create child nodes.

static create(name: str, command: ChannelCommandProcessor, source: ChannelEnvironmentSource, logger: Logger | LoggerAdapter[Any], app: AppInfo, channel_pattern: PatternPair) ChannelEnvironmentDisplay[source]#

Create a channel-environment display.

handle_cell_selected(event: CellSelected) None[source]#

Handle input submission.

property label: str#

Obtain a label string for this instance.

model: Model#
on_mount() None[source]#

Populate channel table.

random_channel() None[source]#

Switch to a random channel.

reset_plot() None[source]#

Reset the selected plot.

row_idx: int#
selected: SelectedChannel#
switch_to_channel(row: int) None[source]#

Switch the plot to a channel at the specified row.

update_channels(max_plot_samples: int, update_table: bool = True, update_log: bool = True, update_plot: bool = True) None[source]#

Update all channel values.

class conntextual.ui.ChannelEnvironmentSource(*values)[source]#

Bases: StrEnum

Possible sources of channel environments.

CONNECTION_LOCAL = 'local connection'#
CONNECTION_REMOTE = 'remote connection'#
TASK = 'task'#
async conntextual.ui.test(app: AppInfo) int[source]#

Run a textual application.