Skip to content

trading_agent.terminal.widgets.keys_screen

A dialog listing the terminal program's keys and its own commands, opened with ? or /keys.

Typical usage example:

app.push_screen(KeysScreen())

KeysScreen

KeysScreen()

Bases: ModalScreen[None]

The list of keys and terminal commands.

Creates the dialog.

Source code in src/trading_agent/terminal/widgets/keys_screen.py
def __init__(self):
    """Creates the dialog."""
    super().__init__(classes='picker-screen')

compose

compose()

Builds the dialog.

Yields:

Type Description
Widget

The title, the keys, the terminal commands and the hint.

Source code in src/trading_agent/terminal/widgets/keys_screen.py
def compose(self):
    """Builds the dialog.

    Yields:
        Widget: The title, the keys, the terminal commands and the hint.
    """
    with containers.VerticalScroll(classes='picker keys'):
        yield widgets.Static('[b]Keys[/b]', classes='picker-title')
        yield widgets.Static(self._two_columns(_KEYS))
        yield widgets.Static(
            '[b]Terminal commands[/b]  [dim]every other /command goes to the desk; try /help[/dim]',
            classes='picker-title keys-section',
        )
        yield widgets.Static(self._two_columns(_COMMANDS))
        yield widgets.Static(
            '[dim]esc to close[/dim]', classes='picker-hint'
        )

action_close

action_close()

Closes the dialog.

Source code in src/trading_agent/terminal/widgets/keys_screen.py
def action_close(self) -> None:
    """Closes the dialog."""
    self.dismiss(None)

TerminalCommandList

The terminal program's own commands, for the command menu.

entries

entries()

The commands as menu entries.

Returns:

Type Description
list[dict[str, str]]

Each with name, usage and description.

Source code in src/trading_agent/terminal/widgets/keys_screen.py
def entries(self) -> list[dict[str, str]]:
    """The commands as menu entries.

    Returns:
        list[dict[str, str]]: Each with name, usage and description.
    """
    entries = []
    for usage, description in _COMMANDS:
        entries.append(
            {
                'name': usage.split()[0],
                'usage': usage,
                'description': description,
            }
        )
    return entries