π’<SelectionInterface> Class Doc.
The SelectInterface
class is a user input handler for command-line interface (CLI) applications, designed to display a menu of options to the user and capture their selection. It simplifies gathering and managing user input across various parts of an application by displaying a list of options and processing the user's choice.
Key Usage Areas:
LS_Interface (
do_add
,do_transfer
): For adding or transferring items, allowing users to select from available options.NW_Interface (
handle_homologous_responses
): To handle user choices in situations requiring a decision among homologous responses.PrimaryInterface (
do_grab
,do_cd
): Facilitates file grabbing and directory navigation through user selections.
How to Use:
Initialization: Instantiate
SelectInterface
with a list of options, a reference to the parent CLI (for response delivery), and optional header and tail statements for context.Display Menu: Automatically displays the options menu upon instantiation. The user is prompted to select an option by typing its number or a specific command.
Capture Selection: The user's selection is processed and delivered to the parent CLI's
response
attribute, making it available for further processing.Exit: Users can exit the menu by pressing Enter on an empty line or by typing an
exit
command if implemented.
statement_1 = f"Found {len(homologous)} homologous."
statement_2 = "(Enter 'lemma' to create a new meaning or press Enter to move on.)"
formatted_nodes = [node._convert_header_to_compact_format() for node in homologous]
SelectInterface(formatted_nodes, self,
statement_1, statement_2,
'Lemma: ').cmdloop()
response = self._get_response()
Last updated