tui
dev_tool.tui
__all__ = ['Action', 'ActionGroup', 'CommandAction', 'DisplayAction', 'Menu', 'MenuElement', 'MenuFactory', 'MenuItem', 'SubmenuAction']
module-attribute
Action
Bases: Protocol
A protocol for menu actions.
This class defines the interface for executing actions in the TUI menu.
run
is_submenu
A method that checks if this action is a submenu action.
Returns:
-
bool–True if this is a submenu action, False otherwise.
get_action_type
CommandAction
dataclass
A class for executing commands from the TUI menu.
This class runs a command function when selected from the menu.
command
instance-attribute
run
A method that stores the command for execution after exiting cbreak mode.
Parameters:
-
controller(MenuController) –The menu controller.
is_submenu
A method that checks if this action is a submenu action.
Returns:
-
bool–True if this is a submenu action, False otherwise.
get_action_type
DisplayAction
dataclass
A class for displaying scrollable content in the TUI.
This class displays content within the TUI loop without exiting cbreak mode, allowing for scrolling and navigation back to the menu.
content
instance-attribute
run
A method that displays the content in the TUI display view.
Parameters:
-
controller(MenuController) –The menu controller.
is_submenu
A method that checks if this action is a submenu action.
Returns:
-
bool–True if this is a submenu action, False otherwise.
get_action_type
SubmenuAction
dataclass
A class for opening submenus from the TUI menu.
This class navigates to a submenu when selected from the menu.
submenu
instance-attribute
run
A method that opens the submenu.
Parameters:
-
controller(MenuController) –The menu controller.
Source code in dev_tool/tui/menu/action.py
is_submenu
A method that checks if this action is a submenu action.
Returns:
-
bool–True if this is a submenu action, False otherwise.
get_action_type
ActionGroup
Bases: StrEnum
An enumeration of action groups for the TUI menu.
COMMAND = 'command'
class-attribute
instance-attribute
DISPLAY = 'display'
class-attribute
instance-attribute
SUBMENU = 'submenu'
class-attribute
instance-attribute
MenuFactory
A factory class for creating TUI menus.
This class provides static methods for creating different types of menus.
create_main_menu
staticmethod
A method that creates the main menu.
Returns:
-
Menu–The main menu.
Source code in dev_tool/tui/menu/factory.py
Menu
dataclass
A data class representing a TUI menu.
A menu contains a title and a list of menu items.
title
instance-attribute
items
instance-attribute
label
property
__hash__
get_items
A method that gets the items of this menu.
Returns:
get_element_type
as_menu
as_menu_item
MenuItem
dataclass
A data class representing a TUI menu item.
A menu item contains a label and an action to perform when selected.
label
instance-attribute
action
instance-attribute
__hash__
get_items
A method that returns an empty list since menu items have no sub-items.
Returns:
get_element_type
A method that returns the type of element as a string.
Returns:
-
str–The element type string based on the action.