def process_data(name, data, page, nested=None): if isinstance(data, Exception): Screen().input(f"DError: {data}") return subtitle = "".join(f"{i} " for i in columns[name]) arr = [f" Page {page - 1}", f" Page {page + 1}"] for en in data: arr.append(" ".join(map(str, en))) sel = SelectionMenu.get_selection(arr, subtitle) if sel in range(2, len(arr)): subtitle = "" for i in range(len(columns[name])): subtitle += f"{columns[name][i]}: {data[sel - 2][i]}; " menu = ConsoleMenu("Item actions", subtitle) if name == "Seller" and nested == None: menu.append_item( FunctionItem("Find products", find_products, [data[sel - 2][0], 1])) elif name == "Product" and nested == None: menu.append_item( FunctionItem("Find sellers", find_sellers, [data[sel - 2][0], 1])) menu.append_item( FunctionItem("Edit", update, [name, columns[name][0], data[sel - 2][0]])) menu.append_item( FunctionItem("Delete", delete, [name, columns[name][0], data[sel - 2][0]])) menu.show() elif sel < 2: return sel + 1
def select_scan(): global lightsheetPackages, lightsheetScanPaths, displayNames scanIndex = SelectionMenu.get_selection(displayNames) if scanIndex >= len(displayNames): return None scanName = displayNames[scanIndex] scan = lightsheetPackages[scanIndex] attribs = scan.get_filled_attr_dict() # TODO: Open the scan and spawn the GUI showing the metadata and thumbnail analysisList = ['3D Density Map', 'Stroke Volume', 'Vessel Diameter'] scanMenu = ConsoleMenu(scanName, exit_option_text="Close Scan") viewAttribsItem = FunctionItem("View Metadata", show_scan_metadata, [attribs]) viewMaxProjItem = FunctionItem("View Max-Proj", show_scan_maxproj, [attribs['maxProjPath'], attribs['name']]) #selectAnalysisPackageItem = FunctionItem("View Analysis", select_existing_analysis, [analysisList]) #createNewAnalysisPackageItem = FunctionItem("Import Analysis", perform_new_analysis, [analysisList]) downloadScanItem = FunctionItem("Download Copy", download_scan, [scan.get_uniqueID()]) scanMenu.append_item(viewAttribsItem) scanMenu.append_item(viewMaxProjItem) #scanMenu.append_item(selectAnalysisPackageItem) #scanMenu.append_item(createNewAnalysisPackageItem) scanMenu.append_item(downloadScanItem) scanMenu.show()
def vm_menu(): menu = ConsoleMenu("Virtual Machine", "Created with Python") submenu = ConsoleMenu("About Us") submenu.prologue_text = "This is Virtual Machine. Created by Vilnius Gediminas " \ "Technical University PRIfs 18/6 student - Rimvydas Kanapka." \ " This program is created for Architecture of Computers and Computer Networks." menu.append_item(FunctionItem("Start VM", main)) # First menu item menu.append_item(SubmenuItem("About Us", submenu, menu=menu)) # Second menu item menu.show()
def tm_menu(): menu = ConsoleMenu("Turing Machine Simulator", "Created with Python") submenu = ConsoleMenu("About Us") submenu.prologue_text = "This is Turing Machine Simulator created by Vilnius Gediminas Technical University " \ "PRIfs 18/6 student - Rimvydas Kanapka." \ " This program is created for Architecture of Computers and Computer Networks." menu.append_item(FunctionItem("RUN Turing Machine", action)) # First menu item menu.append_item(SubmenuItem("About Us", submenu, menu=menu)) # Second menu item menu.show()
def menu(): """ Make use of an interactive menu. """ interactive_menu = ConsoleMenu("Welcome to qr-rocket menu", "Select an option") interactive_menu.append_item( CommandItem("Create a new PDF file", "rocketqr create")) interactive_menu.append_item( CommandItem("Delete all auto generated files", "rocketqr delete")) interactive_menu.append_item( CommandItem("Go to templates menu", "rocketqr templates menu")) interactive_menu.show()
def manage_emulations(emulations): """ Start/stop/delete an emulation, or view its devices. :param emulations: List of emulations to manage """ prologue_text = "\n".join( ["{} ({})".format(e.name, e.status) for e in emulations]) menu = ConsoleMenu(title="Manage Emulations", prologue_text=prologue_text) menu.append_item( FunctionItem("Start", api.toggle_emulations, args=[emulations, "start"], should_exit=True)) menu.append_item( FunctionItem( "Start w/timer", api.toggle_emulations, args=[emulations, "start", True], should_exit=True, )) menu.append_item( FunctionItem( "Stop", api.toggle_emulations, args=[emulations, "suspend"], should_exit=True, )) menu.append_item( FunctionItem("Delete", api.toggle_emulations, args=[emulations, "stop"], should_exit=True)) # Present this option only when managing a single emulation to enable/disable devices if len(emulations) == 1: menu.append_item( FunctionItem("Show Devices", select_devices, args=[emulations[0].id])) # Present this option to enable/disable multiple devices on multiple emulations else: menu.append_item( FunctionItem( "Multi-Emulation Enable/Disable Devices", manage_devices_across_emulations, args=[emulations], )) menu.show()
def main(): """ Run the intial setup script, check for an input file and show the main menu """ init_script() read_info_file() # Define Menu menu = ConsoleMenu( title="AWS EC2 and S3 Webserver Configuration Script", subtitle="Developer Operations Assignment 1 - Dylan Gore", ) # Define menu options and what they do opt_full_run = FunctionItem("Run automatic configuration", wait_func, [full_run]) opt_user_input = FunctionItem("Input custom settings", wait_func, [accept_user_input]) opt_active = FunctionItem("List running instances/active buckets", wait_func, [list_active]) opt_monitoring = FunctionItem("Display monitoring info", wait_func, [display_monitor]) # opt_website = FunctionItem("Check if web server is running", wait_func, [check_website]) # opt_iam = FunctionItem("Create IAM role & policy", wait_func, [check_for_iam_role, iam, sts_client]) opt_configure_aws = CommandItem("Configure AWS credentials and Settigns", "aws configure") opt_load_config_file = FunctionItem("Load configuration file", wait_func, [read_info_file]) opt_cleanup = FunctionItem("Cleanup AWS", wait_func, [cleanup]) opt_clear_logs = FunctionItem("Clear logs", wait_func, [clear_logs]) # Add options to menu menu.append_item(opt_full_run) menu.append_item(opt_user_input) menu.append_item(opt_active) menu.append_item(opt_monitoring) # menu.append_item(opt_website) # menu.append_item(opt_iam) menu.append_item(opt_configure_aws) menu.append_item(opt_load_config_file) menu.append_item(opt_cleanup) menu.append_item(opt_clear_logs) # Display the menu and wait for user input menu.show() # Print when user runs the 'Exit' option print("Exiting...")
def utf_menu(): menu = ConsoleMenu("Decimal number convertor & File Decoder", "Created with Python") submenu = ConsoleMenu("About Us") submenu.prologue_text = "This is Decimal number convertor which takes a decimal number as a input and shows " \ "number's Unicode, UTF-8 and single character. Created by Vilnius Gediminas " \ "Technical University PRIfs 18/6 student - Rimvydas Kanapka." \ " This program is created for Architecture of Computers and Computer Networks." menu.append_item( FunctionItem("GET Unicode, UTF-8 & Char of a Decimal Number", get_info)) # First menu item menu.append_item(FunctionItem("Decode File", decode)) # Second menu item menu.append_item(SubmenuItem("About Us", submenu, menu=menu)) # Third menu item menu.show()
def manually_mod_settings(set_dict): #quick and dirsty workaround - older settings files don't include rand, d. if 'RANDOM_DISABLE_CHANCE' not in set_dict.keys(): set_dict['RANDOM_DISABLE_CHANCE'] = RANDOM_DISABLE_CHANCE menu = ConsoleMenu("Tune parameters", "[original value] / <new value>") menu_items = [] for idx, (key, val) in enumerate(set_dict.items()): desc = f"{key}[{val}]" prompt = f"{key}[{val}] : " def prompt_func(text, set_key): value = input(text) if set_key in ['PID_ENABLED', 'COLLISION']: set_dict[set_key] = True if value.startswith( ('T', 't')) else False elif set_key == 'PID_PARAMS': set_dict[set_key] = [ float(x) for x in value.replace(' ', ',').split(',') ] elif isInt(float(value)): set_dict[set_key] = int(value) else: set_dict[set_key] = float(value) return value if key in ['PID_ENABLED', 'COLLISION']: prompt = f"{key}[{val}](F/T) : " if key == 'PID_PARAMS': prompt = "PID <P I D>: " menu_items.append(FunctionItemMod(desc, prompt_func, [prompt, key])) else: menu_items.append(FunctionItemMod(desc, prompt_func, [prompt, key])) menu.append_item(menu_items[idx]) def print_sett(): for key, item in set_dict.items(): print(f"{key} : {item}") input('\nPress any key to return!') menu.append_item(FunctionItem("PRINT CURRENT SETTINGS", print_sett)) menu.show() return set_dict
def output_console_menu(): start_directory = os.getcwd() directory_content = get_directory_content(start_directory, False) file_selection_menu = ConsoleMenu("Select file from:", start_directory) for current_dir_item in directory_content: current_dir_item_path = start_directory + os.path.sep + current_dir_item if os.path.isfile(current_dir_item_path): file_selection_menu.append_item(FunctionItem(current_dir_item, get_statistic, [current_dir_item_path, tasks_list])) elif os.path.isdir(current_dir_item_path): current_sub_menu = ConsoleMenu("Select file from:", current_dir_item_path) for current_subdir_item in get_directory_content(current_dir_item_path, True): current_sub_menu.append_item(FunctionItem(current_subdir_item, get_statistic, [ current_dir_item_path + os.path.sep + current_subdir_item, tasks_list])) file_selection_menu.append_item(SubmenuItem(current_dir_item + os.path.sep, current_sub_menu)) file_selection_menu.show()
def main(): if len(argv) < 2: menu = ConsoleMenu("Mechanism Types", "Choose which mechanism you are characterizing") for mechanism, tools in tool_dict.items(): tool_menu = ConsoleMenu(f"Characterization Tools: {mechanism}") for tool, function in tools.items(): tool_menu.append_item( FunctionItem(tool, function, menu=tool_menu)) menu.append_item(SubmenuItem(mechanism, tool_menu, menu)) menu.show() else: parser = argparse.ArgumentParser( description="FRC characterization tools CLI") parser.add_argument( "mech_type", choices=list(tool_dict.keys()), help="Mechanism type being characterized", ) parser.add_argument( "tool_type", choices=list(list(tool_dict.values())[0].keys()), help= "Create new project, start data recorder/logger, or start data analyzer", ) parser.add_argument( "project_directory", help= "Location for the project directory (if creating a new project)", nargs="?", default=None, ) argcomplete.autocomplete(parser) args = parser.parse_args() tool_dict[args.mech_type][args.tool_type]( directory=args.project_directory)
def init_menu(self): titulo = "Menú principal" subtitulo = "Programa para cifrar ficheros con AES 256 GCM" prologue = "Para poder encriptar ficheros tiene que estar situados en la carpeta files."\ " Los ficheros *.encrypted y *.decrypted se situarán en la misma carpeta." if not os.path.exists("./my_keystore.jks"): prologue += " PARA HACER USO DE LAS FUNCIONES DE ENCRIPTADO Y DESENCRIPTADO, DEBE CREAR UN ALMACÉN DE CLAVES Y UNA CLAVE (3)." menu = ConsoleMenu(titulo, subtitulo, prologue_text=prologue) cifrado = FunctionItem("Cifrado del fichero", self.encrypt) descifrado = FunctionItem("Descifrado del fichero", self.decrypt) generado_claves = FunctionItem("Generar nueva clave privada", self.generate_key) menu.append_item(cifrado) menu.append_item(descifrado) menu.append_item(generado_claves) menu.show()
def manage_devices(devices): """ Enable/disable a device :param devices: A device object """ prologue_text = "\n".join([ "{} ({})".format(d.name, "Enabled" if d.is_enabled else "Disabled") for d in devices ]) menu = ConsoleMenu(title="Emulation > Devices", prologue_text=prologue_text) menu.append_item( FunctionItem("Enable", api.toggle_devices, args=[devices, True], should_exit=True)) menu.append_item( FunctionItem("Disable", api.toggle_devices, args=[devices, False], should_exit=True)) menu.show()
def main(): init() # Define main menu menu = ConsoleMenu( title="Music Library Manager", subtitle="Main Menu", ) # Define add menu addMenu = ConsoleMenu( title="Music Library Manager", subtitle="Where would you like to add a new track?", exit_option_text="Back" ) # Define main menu options opt_display = FunctionItem( "Display Music Library", wait_func, [displayLibrary]) opt_add = SubmenuItem("Add a new track", addMenu) # Define add menu options opt_add_start = FunctionItem( "At the beginning of the list", wait_func, [addTune]) # Add options to the main menu menu.append_item(opt_add) menu.append_item(opt_display) # Add options to the add menu addMenu.append_item(opt_add_start) # Display the menu and wait for user input menu.show() # Print when user runs the 'Exit' option print("Exiting...")
def main(): #List containing the choices of the user desired_properties: List[DesiredProperty] = [] #Load ontology amsterdam_neighbourhoods = pd.read_csv("data/amsterdam.csv") # Create the menu menu = ConsoleMenu("AreA", "An advisor on Amsterdam's residential areas") # Menu Items desired_prop_item = FunctionItem("Add desired property", desired_prorerty_submenu, [desired_properties]) view_sugg_item = FunctionItem( "Get suggestions", view_suggestions_func, [amsterdam_neighbourhoods, desired_properties]) # Once we're done creating them, we just add the items to the menu menu.append_item(desired_prop_item) menu.append_item(view_sugg_item) # start menu menu.show()
m_notes.append_item( FunctionItem('Show notes', interface.wrapShow, ['notes'])) m_related = ConsoleMenu('Sites') m_related.append_item( FunctionItem('Add new related site', interface.wrapAddRelated)) m_related.append_item( FunctionItem('Remove existed related site', interface.wrapRemRelated)) m_related.append_item( FunctionItem('Show related sites', interface.wrapShow, ['related'])) m_structure = ConsoleMenu('Structure') m_structure.append_item(FunctionItem('Add new page', interface.wrapAddPage)) m_structure.append_item(FunctionItem('Remove page', interface.wrapRemPage)) m_structure.append_item( FunctionItem('Add parameter to page', interface.wrapAddArg)) m_structure.append_item( FunctionItem('Remove parameter from page', interface.wrapRemArg)) m_structure.append_item( FunctionItem('Change parameter on page', interface.wrapChangeArg)) m_structure.append_item( FunctionItem('Show structure', interface.wrapShow, ['structure'])) m_main.append_item(SubmenuItem('Notes', m_notes, menu=m_main)) m_main.append_item(SubmenuItem('Related sites', m_related, menu=m_main)) m_main.append_item(SubmenuItem('Structure', m_structure, menu=m_main)) m_main.append_item(FunctionItem('Save project', interface.wrapSave)) m_main.show()
# Creates the individual components of the submenu 'Passwordmanager menu' password_stuff.append_item( FunctionItem("Show all stored entries", show_database_entries)) password_stuff.append_item( FunctionItem("Add database entry", create_database_entry)) password_stuff.append_item( FunctionItem("Modify database entry", modify_database_entry)) password_stuff.append_item( FunctionItem("Delete database entry", delete_database_entry)) password_stuff.append_item( FunctionItem("Password generator", password_generator)) # Creates the submenu 'Database menu' database_stuff = ConsoleMenu(f"Database menu", "Select an option!") database_stuff_submenu = SubmenuItem("Database Menu", database_stuff, menu) # Creates the individual components of the submenu 'Database menu' database_stuff.append_item( FunctionItem("Create a new database", database_setup)) database_stuff.append_item( FunctionItem("Select a database to read from", database_enable)) database_stuff.append_item( FunctionItem("Check selected database", check_selected_database)) # Everything gets added to the main Menu menu.append_item(database_stuff_submenu) menu.append_item(password_stuff_submenu) menu.append_item(FunctionItem("About", about)) menu.show(True)
from consolemenu import ConsoleMenu from consolemenu.items import FunctionItem, SubmenuItem, CommandItem menu = ConsoleMenu(title='Menu Title', subtitle='Subtitle') command_item = CommandItem('Run a console command!', 'touch.txt') function_item = FunctionItem('call a function', input, ['enter input']) submenu = ConsoleMenu('a submenu') submenu_item = SubmenuItem('show a submenu', submenu, menu=menu) menu.append_item(command_item) menu.append_item(function_item) menu.append_item(submenu_item) # menu.start() # menu.join() menu.show()
def menu(): menu = ConsoleMenu("Timelapse Server Console") menu.append_item(FunctionItem("Process the past", runDailyProcess)) menu.append_item(FunctionItem("Preview today", previewToday)) menu.show()
epilogue_text=lightsheetEpilogue, exit_option_text="Main Menu") lightsheetItem = SubmenuItem("Lightsheet Data", lightsheetMenu, mainMenu) ephysMenu = ConsoleMenu("EPhys Data [Not Implemented]", exit_option_text="Main Menu") ephysItem = SubmenuItem("Ephys Data", ephysMenu, mainMenu) confocalMenu = ConsoleMenu("Confocal Data [Not Implemented]", exit_option_text="Main Menu") confocalItem = SubmenuItem("Confocal Data", confocalMenu, mainMenu) behaviorMenu = ConsoleMenu("Behavior Data [Not Implemented]", exit_option_text="Main Menu") behaviorItem = SubmenuItem("Behavior Data", behaviorMenu, mainMenu) cellCultureMenu = ConsoleMenu("Cell Culture Data [Not Implemented]", exit_option_text="Main Menu") cellCultureItem = SubmenuItem("Cell Culture Data", cellCultureMenu, mainMenu) openScanMenuItem = FunctionItem("Open Scan", select_scan, [], menu=lightsheetMenu) importScanMenuItem = FunctionItem("Import Scan", create_scan, []) mainMenu.append_item(lightsheetItem) mainMenu.append_item(ephysItem) mainMenu.append_item(confocalItem) mainMenu.append_item(behaviorItem) mainMenu.append_item(cellCultureItem) lightsheetMenu.append_item(openScanMenuItem) lightsheetMenu.append_item(importScanMenuItem) mainMenu.show()
def templates_menu(): templates_menu = ConsoleMenu("You are in qr-rocket templates menu", "Select an option") templates_menu.append_item(CommandItem("Show templates", "rocketqr templates show")) templates_menu.append_item(CommandItem("Create new template", "rocketqr templates create")) templates_menu.append_item(CommandItem("Go back to main menu", "rocketqr menu")) templates_menu.show()
def main(): # Create the menu menu = ConsoleMenu( "Lena's Bank main menu", "Welcome to Lena's Bank! Please select from the following menu:") # A FunctionItem runs a Python function when selected list_of_all_customers_function = FunctionItem("List of all customers", bank.list_of_all_customers) find_customer_function = FunctionItem("Find customer by SSN", bank.find_customer) update_customer_info_function = FunctionItem("Update customer info", bank.update_customer) remove_customer_function = FunctionItem("Remove customer", bank.remove_customer) add_new_customer_function = FunctionItem("Add new customer", bank.add_new_customer) get_balance_function = FunctionItem("Get balance", bank.get_balance) open_new_account_function = FunctionItem("Open New Account", bank.open_new_account) close_account_function = FunctionItem("Close account", bank.close_account) add_new_transaction_function = FunctionItem("Add new transaction", bank.add_new_transaction) view_transaction_history_function = FunctionItem( "View transaction history", bank.transaction_history) list_of_all_customers_submenu_item = SelectionMenu([]) list_of_all_customers_submenu_item.append_item( list_of_all_customers_function) list_of_all_customers_submenu_item.append_item(find_customer_function) list_of_all_customers_submenu_item.append_item( update_customer_info_function) list_of_all_customers_submenu_item.append_item(add_new_customer_function) list_of_all_customers_submenu_item.append_item(remove_customer_function) work_with_accounts_selection_menu = SelectionMenu([]) work_with_accounts_selection_menu.append_item(get_balance_function) work_with_accounts_selection_menu.append_item(open_new_account_function) work_with_accounts_selection_menu.append_item(close_account_function) process_transactions_selection_menu = SelectionMenu([]) process_transactions_selection_menu.append_item( add_new_transaction_function) process_transactions_selection_menu.append_item( view_transaction_history_function) manage_customers_submenu_item = SubmenuItem( "Manage customers", list_of_all_customers_submenu_item, menu) accounts_submenu_item = SubmenuItem("Work with accounts", work_with_accounts_selection_menu, menu) process_transactions_submenu_item = SubmenuItem( "Process Transactions", process_transactions_selection_menu, menu) menu.append_item(manage_customers_submenu_item) menu.append_item(accounts_submenu_item) menu.append_item(process_transactions_submenu_item) models.create_lenas_bank() menu.show()
subtitle=menu_subtitle, prologue_text= "Certo, agora você precisa escolher uma das músicas abaixo para que o classificador tente adivinhar qual o gênero dela:", ) # exibe o menu para seleção da música a ser analisada music_selection_menu.show() selected_network = network_types[ network_selection_menu.selected_option] selected_music = musics[music_selection_menu.selected_option] # faz a previsão dos gêneros que possuem semelhança com a música selecionada predicted_genres = predict_genre(f"songs/{selected_music}", network_type=selected_network) result_menu = ConsoleMenu( title=menu_title, subtitle=menu_subtitle, prologue_text= "De acordo com o algoritmo de '{}', a música '{}' tem similaridade com os seguintes gêneros:" .format(selected_network, selected_music)) # cria os itens do menu de resultados obtidos pela previsão for predicted_genre in predicted_genres: result_menu.append_item( MenuItem("Gênero: {}, Precisão: {:.2f}%".format( predicted_genre['label'], predicted_genre['accuracy']))) result_menu.show()