Skip to content

action

dev_tool.tui.menu.action

log = logging.getLogger(__name__) module-attribute

Action

Bases: Protocol

A protocol for menu actions.

This class defines the interface for executing actions in the TUI menu.

run

A method that executes the action.

Parameters:

Source code in dev_tool/tui/menu/action.py
def run(self, controller: MenuController) -> object | None:
    """
    A method that executes the action.

    :param controller: 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.

Source code in dev_tool/tui/menu/action.py
def is_submenu(self) -> bool:
    """
    A method that checks if this action is a submenu action.

    :return: True if this is a submenu action, False otherwise.
    """

    ...

get_action_type

A method that returns the type of action as an enum.

Returns:

Source code in dev_tool/tui/menu/action.py
def get_action_type(self) -> ActionType:
    """
    A method that returns the type of action as an enum.

    :return: The action type enum.
    """

    ...

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:

Source code in dev_tool/tui/menu/action.py
def run(self, controller: MenuController) -> object:
    """
    A method that stores the command for execution after exiting cbreak mode.

    :param controller: The menu controller.
    """

    controller.running = False
    return self.command

is_submenu

A method that checks if this action is a submenu action.

Returns:

  • bool

    True if this is a submenu action, False otherwise.

Source code in dev_tool/tui/menu/action.py
def is_submenu(self) -> bool:
    """
    A method that checks if this action is a submenu action.

    :return: True if this is a submenu action, False otherwise.
    """

    return False

get_action_type

A method that returns the type of action as an enum.

Returns:

Source code in dev_tool/tui/menu/action.py
def get_action_type(self) -> ActionType:
    """
    A method that returns the type of action as an enum.

    :return: The action type enum.
    """

    return ActionType.COMMAND

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:

Source code in dev_tool/tui/menu/action.py
def run(self, controller: MenuController) -> None:
    """
    A method that displays the content in the TUI display view.

    :param controller: The menu controller.
    """

    controller.views.set_display_content(self.content())

is_submenu

A method that checks if this action is a submenu action.

Returns:

  • bool

    True if this is a submenu action, False otherwise.

Source code in dev_tool/tui/menu/action.py
def is_submenu(self) -> bool:
    """
    A method that checks if this action is a submenu action.

    :return: True if this is a submenu action, False otherwise.
    """

    return False

get_action_type

A method that returns the type of action as an enum.

Returns:

Source code in dev_tool/tui/menu/action.py
def get_action_type(self) -> ActionType:
    """
    A method that returns the type of action as an enum.

    :return: The action type enum.
    """

    return ActionType.DISPLAY

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:

Source code in dev_tool/tui/menu/action.py
def run(self, controller: MenuController) -> None:
    """
    A method that opens the submenu.

    :param controller: The menu controller.
    """

    menu = (
        self.submenu()
        if callable(self.submenu)
        else self.submenu
    )

    controller.ui.set_menu(menu)
    controller.ui.draw_menu()

is_submenu

A method that checks if this action is a submenu action.

Returns:

  • bool

    True if this is a submenu action, False otherwise.

Source code in dev_tool/tui/menu/action.py
def is_submenu(self) -> bool:
    """
    A method that checks if this action is a submenu action.

    :return: True if this is a submenu action, False otherwise.
    """

    return True

get_action_type

A method that returns the type of action as an enum.

Returns:

Source code in dev_tool/tui/menu/action.py
def get_action_type(self) -> ActionType:
    """
    A method that returns the type of action as an enum.

    :return: The action type enum.
    """

    return ActionType.MENU