Karana.KUtils.MultibodyTUI.dialog#

Classes#

EntryDialog

Base class for a user text input TUI

SearchDialog

Base class for a user text input TUI

FlagData

FlagsTUI

Base class for terminal user interfaces

MenuEntry

MenuTUI

Base class for terminal user interfaces

ChoiceData

ChoiceTUI

Base class for terminal user interfaces

Module Contents#

class Karana.KUtils.MultibodyTUI.dialog.EntryDialog(prompt: list[str] | None = None, entry: str = '')[source]#

Base class for a user text input TUI

prompt = None#
entry = ''#
run() str | None[source]#

Run the TUI

This blocks until the user entry is confirmed or canceled

is_valid() bool[source]#
footer() list[str][source]#
redraw()[source]#
class Karana.KUtils.MultibodyTUI.dialog.SearchDialog(universe: list[str], prompt=list[str] | None)[source]#

Bases: EntryDialog

Base class for a user text input TUI

universe#
matches() list[str][source]#
is_valid() bool[source]#
static bold_match(string: str, substr: str) str[source]#
footer() list[str][source]#
class Karana.KUtils.MultibodyTUI.dialog.FlagData[source]#
brief: str#
enabled: bool#
toggle()[source]#
__bool__()[source]#
class Karana.KUtils.MultibodyTUI.dialog.FlagsTUI(header: list[str], flags: list[FlagData])[source]#

Bases: Karana.KUtils.MultibodyTUI.base.TUIBase

Base class for terminal user interfaces

property confirmed#
redraw()[source]#

Redraw the TUI

A concrete TUI class must implement this method

Typically the implementation should first clear the screen then print the TUI interface.

handle_key(key)[source]#

Handle a single key press

A concrete TUI class must implement this method

Parameters:

key (str) – The pressed key as returned by poll_key

Returns:

Return False to indicate the TUI should exit

Return type:

bool

class Karana.KUtils.MultibodyTUI.dialog.MenuEntry[source]#
brief: str#
callback: collections.abc.Callable | None = None#
description: str = ''#
done: bool = False#
class Karana.KUtils.MultibodyTUI.dialog.MenuTUI(header: list[str], entries: list[MenuEntry], index: int = 0)[source]#

Bases: Karana.KUtils.MultibodyTUI.base.TUIBase

Base class for terminal user interfaces

redraw()[source]#

Redraw the TUI

A concrete TUI class must implement this method

Typically the implementation should first clear the screen then print the TUI interface.

footer() list[str][source]#
property current: MenuEntry#
handle_key(key)[source]#

Handle a single key press

A concrete TUI class must implement this method

Parameters:

key (str) – The pressed key as returned by poll_key

Returns:

Return False to indicate the TUI should exit

Return type:

bool

class Karana.KUtils.MultibodyTUI.dialog.ChoiceData[source]#
brief: str#
value: Any#
description: str = ''#
class Karana.KUtils.MultibodyTUI.dialog.ChoiceTUI(header: list[str], choices: list[ChoiceData], index: int = 0)[source]#

Bases: Karana.KUtils.MultibodyTUI.base.TUIBase

Base class for terminal user interfaces

property choice: ChoiceData | None#
redraw()[source]#

Redraw the TUI

A concrete TUI class must implement this method

Typically the implementation should first clear the screen then print the TUI interface.

handle_key(key)[source]#

Handle a single key press

A concrete TUI class must implement this method

Parameters:

key (str) – The pressed key as returned by poll_key

Returns:

Return False to indicate the TUI should exit

Return type:

bool