nexusLIMS.tui.common.base_screens#

Base screen classes for NexusLIMS TUI applications.

Provides reusable screen patterns for common UI tasks like list views, forms, and confirmation dialogs.

Module Contents#

Classes#

BaseListScreen

Base screen for displaying data in a table.

BaseFormScreen

Base screen for add/edit forms.

ConfirmDialog

Modal confirmation dialog.

API#

class nexusLIMS.tui.common.base_screens.BaseListScreen(**kwargs)[source]#

Bases: textual.screen.Screen

Base screen for displaying data in a table.

Subclasses must implement:

  • get_columns() -> list[str]: Column headers

  • get_data() -> list[dict]: Row data

  • on_row_selected(row_key, row_data): Handle row selection

Provides:

  • DataTable with navigation and sorting

  • Search/filter bar

  • Add/Edit/Delete/Quit keybindings

  • Header and footer

CSS_PATH#

Type: typing.ClassVar

BINDINGS#

[(‘a’, ‘add’, ‘Add’), (‘e’, ‘edit’, ‘Edit’), (‘d’, ‘delete’, ‘Delete’), (‘r’, ‘refresh’, ‘Refresh’),…

Type: typing.ClassVar

compose() textual.app.ComposeResult[source]#

Compose the list screen layout.

on_mount() None[source]#

Set up the data table on mount.

refresh_data() None[source]#

Reload data into the table.

on_header_selected(event: textual.widgets.DataTable.HeaderSelected) None[source]#

Handle column header click for sorting.

on_filter_changed(event: textual.widgets.Input.Changed) None[source]#

Handle filter input changes.

action_focus_filter() None[source]#

Focus the filter input.

action_cycle_sort() None[source]#

Cycle through sort columns (press ‘s’ repeatedly to change column).

abstractmethod get_columns() list[str][source]#

Get column headers for the table.

Returns:

Column header names

Return type:

list[str]

abstractmethod get_data() list[dict][source]#

Get data rows for the table.

Returns:

List of row dictionaries (column_name -> value)

Return type:

list[dict]

on_row_selected_event(event: textual.widgets.DataTable.RowSelected) None[source]#

Handle row selection from table.

abstractmethod on_row_selected(row_key, row_data: dict) None[source]#

Handle row selection.

Parameters:
  • row_key – Row key (typically primary key value)

  • row_data (dict) – Dictionary mapping column names to values

action_add() None[source]#

Handle add action (default: no-op, override in subclass).

action_edit() None[source]#

Handle edit action (default: edit selected row).

action_delete() None[source]#

Handle delete action (default: no-op, override in subclass).

action_refresh() None[source]#

Handle refresh action.

action_quit() None[source]#

Handle quit action.

action_help() None[source]#

Show help screen.

class nexusLIMS.tui.common.base_screens.BaseFormScreen(title: str = 'Form', **kwargs)[source]#

Bases: textual.screen.Screen

Base screen for add/edit forms.

Subclasses must implement:

  • get_form_fields() -> ComposeResult: Yield form field widgets

  • validate_form() -> dict[str, str]: Validate and return errors

  • on_save(data: dict): Handle save action

Provides:

  • Form layout with save/cancel buttons

  • Validation on save

  • Header and footer

BINDINGS#

[(‘ctrl+s’, ‘save’, ‘Save’), (‘escape’, ‘cancel’, ‘Cancel’), (‘?’, ‘help’, ‘Help’)]

Type: typing.ClassVar

compose() textual.app.ComposeResult[source]#

Compose the form layout.

abstractmethod get_form_fields() textual.app.ComposeResult[source]#

Get form field widgets.

Yields:

Widget – Form field widgets (typically FormField instances)

abstractmethod validate_form() dict[str, str][source]#

Validate form data.

Returns:

Dictionary mapping field names to error messages. Empty dict if validation passes.

Return type:

dict[str, str]

abstractmethod on_save(data: dict) None[source]#

Handle save action.

Parameters:

data (dict) – Form data (field_name -> value)

action_save() None[source]#

Handle save action with validation.

on_save_button() None[source]#

Handle save button press.

on_cancel_button() None[source]#

Handle cancel button press.

action_cancel() None[source]#

Handle cancel action.

action_help() None[source]#

Show help screen.

collect_form_data() dict[source]#

Collect data from all form fields.

Returns:

Field name to value mapping

Return type:

dict

class nexusLIMS.tui.common.base_screens.ConfirmDialog(message: str, title: str = 'Confirm', **kwargs)[source]#

Bases: textual.screen.ModalScreen[bool]

Modal confirmation dialog.

Displays a message and Yes/No buttons. Returns True if user confirms, False if they cancel.

Parameters:
  • message (str) – Confirmation message to display

  • title (str) – Dialog title

CSS_PATH#

Type: typing.ClassVar

compose() textual.app.ComposeResult[source]#

Compose the dialog layout.

on_yes() None[source]#

Handle yes button.

on_no() None[source]#

Handle no button.