def search_video_yt(options): youtube = build(config.YT_API_SERVICE_NAME, config.YT_API_VERSION, developerKey=config.DEVELOPER_KEY) search_response = youtube.search().list(q=options.q, part='id, snippet', maxResults=int(options.max_results) + 1)\ .execute() videos = [] videos_id = [] for search_result in search_response.get("items", []): if search_result["id"]["kind"] == "youtube#video": videos.append(search_result["snippet"]["title"]) videos_id.append(search_result["id"]["videoId"]) video_titles_without_emojis = [] for video in videos: removing_emoji = remove_emoji(video) video_titles_without_emojis.append(removing_emoji) print(colored("Choose your video:", 'grey', 'on_white')) terminal_menu = TerminalMenu(video_titles_without_emojis) menu_entry_index = terminal_menu.show() return videos_id[menu_entry_index]
def main(): #tick_str = input("Ticker: ") #tick = yf.Ticker(tick_str) #tick_history = tick.history(period="max") #data = parse(tick.history(period="max")) #tick_history.to_csv('tmp.csv', encoding='utf-8', index=True) #print(tick_history) exit = 0 while (exit == 0): title = "Select Mode" main_menu = TerminalMenu( ["Buy and Hold: Yr", "Buy and Hold: Day", "Exit"], title) selection = main_menu.show() if (selection == 0): min = int(input("min: ")) max = int(input("max: ")) + 1 range = int(input("range: ")) buy_hold_year(min, max, range) #buy_hold_year(data, min, max,range) elif (selection == 1): min = int(input("min: ")) max = int(input("max: ")) + 1 range = int(input("range: ")) buy_hold_day(min, max, range) #buy_hod_day(data, min, max, range) else: exit = 1
def fixup(*, cli_args: str = None, doc: str = None): global log args = hedgehog.init( _init_fixup, arguments=cli_args, logger=True, argp_kwargs=dict(description=doc, usage="%(prog)s [opts] [git-commit args]"), ) log = logging.getLogger(args.prog_name) log.debug(args) lines = (common.git_command("log", "--oneline", "--decorate", "-n", args.max_count).strip().splitlines()) commits = [(line, line.split(maxsplit=1)[0]) for line in lines] log.debug_obj(commits, "Commits") menu = TerminalMenu( ("|".join(c) for c in commits), preview_command="git log -1 {}", cycle_cursor=False, preview_size=0.4, show_search_hint=True, ) index = menu.show() if index is None: return log.debug("Selected index: %s, commit: %s", index, commits[index]) git_args = [ "commit", *args.remainder, args.commit_type, commits[index][1], ] common.print_git_command(git_args, f" # ({commits[index][0]})") common.git_command(*git_args)
def mainMenu(): main_menu_title = ' Main Menu\n' main_menu_items = ['New room', 'Inventar', 'Teleport', 'Customize NOT WORKING PROPERLY !', 'Quit', ' ', 'Admin'] main_menu = TerminalMenu ( title = main_menu_title, menu_entries = main_menu_items, menu_cursor = menu_cursor, menu_cursor_style = menu_cursor_style, menu_highlight_style = menu_style, cycle_cursor = True, clear_screen = True ) main_menu_exit = False #with open(str(player + '.purse')) while not main_menu_exit: main_sel = main_menu.show() if main_sel == 0: newRoom() elif main_sel == 1: Inventar() elif main_sel == 2: Teleport() elif main_sel == 3: Customize() main_menu_exit = True elif main_sel == 4: print('Quitting..') sys.exit() elif main_sel == 6: admin()
def get_options(): parser = argparse.ArgumentParser(description='Generate a bind/reverse shell') # Can't choose bind shell and reverse shell shelltype = parser.add_mutually_exclusive_group() shelltype.add_argument('-b', '--bind-shell', dest='SHELLTYPE', action='store_const', const='bind', help='Generate a bind shell (you connect to the target)') shelltype.add_argument('-r', '--reverse-shell', dest='SHELLTYPE', action='store_const', const='reverse', help='Generate a reverse shell (the target connects to you) (Default)') # Sets reverse shell as default value for SHELLTYPE (https://stackoverflow.com/questions/38507675/python-argparse-mutually-exclusive-group-with-default-if-no-argument-is-given) parser.set_defaults(SHELLTYPE = 'reverse') # Creates group of options for bindshell bindshell = parser.add_argument_group('Bind shell options') # typeoptions and portoption are two options either bindshell or revshell will need (https://stackoverflow.com/questions/23775378/allowing-same-option-in-different-argparser-group) typeoption = bindshell.add_argument('-t', '--type', dest='TYPE', type=str.lower, help='Type of the shell to generate (Bash, Powershell, Java...)') portoption = bindshell.add_argument('-p', '--port', dest='LPORT', type=int, help='Listener Port (required for reverse shells)') revshell = parser.add_argument_group('Reverse shell options') revshell._group_actions.append(typeoption) revshell.add_argument('-i', '--ip', dest='LHOST', type=str, help='Listener IP address (required for reverse shells)') revshell._group_actions.append(portoption) options = parser.parse_args() if options.SHELLTYPE == 'reverse' and not options.LHOST: parser.error('Listener IP address not supplied') if not options.LPORT: parser.error('Listener IP port not supplied') if not options.TYPE: if options.SHELLTYPE == 'reverse': shells_dict = revshells elif options.SHELLTYPE == 'bind': shells_dict = bindshells menu = TerminalMenu(list(shells_dict.keys()), title='What type of shell do you want?') selection = menu.show() options.TYPE = list(shells_dict.keys())[selection] return options
def navigate_questions_panel(self, playbook=False): # Code for navigating through the question panel if playbook: message = 'Playbook Questions' instructions = ". Press 'd' to delete from playbook" keys = ('enter', 'd') else: message = 'Relevant Questions' instructions = ". Press 'p' to save in playbook" keys = ('enter', 'p') console.rule('[bold blue] {}'.format(message), style="bold red") console.print("[yellow] Use arrow keys to navigate." + "'q' or 'Esc' to quit. 'Enter' to open in a browser" + instructions) console.print() options = ["|".join(map(str, question)) for question in self.questions_data] question_menu = TerminalMenu(options, preview_command=self.return_formatted_ans, preview_size=0.75, accept_keys=keys) quitting = False while not(quitting): options_index = question_menu.show() try: question_link = self.questions_data[options_index][2] except Exception: return sys.exit() if playbook else None else: if(question_menu.chosen_accept_key == 'enter'): webbrowser.open(question_link) elif(question_menu.chosen_accept_key == 'p'): self.playbook.\ add_to_playbook(self, self.questions_data[options_index][1]) elif(question_menu.chosen_accept_key == 'd' and playbook): self.playbook.\ delete_from_playbook(self, self.questions_data[options_index][1])
def colorScheme(): menu_title = ' Select a Color Scheme' menu_items = ['red', 'blue', 'back'] menu_back = False menu_back = False menu = TerminalMenu( title = menu_title, menu_entries = menu_items, menu_cursor = '-> ', menu_cursor_style = ('fg_red', 'bold'), menu_highlight_style = ('bg_red', 'fg_yellow'), cycle_cursor = True, clear_screen = True ) global menu_cursor_style global menu_style while not menu_back: menu_sel = menu.show() if menu_sel == 0: menu_style = ('bg_red', 'fg_yellow') menu_cursor_style = ('bg_red', 'bold') elif menu_sel == 1: menu_style = ('bg_blue', 'fg_gray') menu_cursor_style = ('bg_blue', 'bold') if menu_sel == 2: menu_back = True Customize()
def main(): current_notes = _get_all_notes() def view_note(key: str): print("{0}: {1}".format(key,current_notes[key])) options = {} for k in list(current_notes.keys()): options[k] = view_note options["New Note"] = add_note options["Delete Note"] = remove_note options["Exit"] = leave choices: list = list(options.keys()) menu = TerminalMenu(choices,title=colored('Notes (↑/↓)',color='blue')) choice = menu.show() choice = choices[choice] os.system('clear') if choice not in list(current_notes.keys()): options[choice]() else: options[choice](key=choice)
def menu(title, menu_list): if platform.system() == 'Windows': selection = SelectionMenu.get_selection(menu_list, title=title, show_exit_option=False) else: menu = TerminalMenu(menu_list, title=title) selection = menu.show() return menu_list[selection]
def choose(): """!!!this is f*****g wrong intendet!!!""" menu_title = ' Choose what you want to choose' menu_items = ['weapons', 'armor', 'back'] menu_back = False menu = TerminalMenu ( title = menu_title, menu_entries = menu_items, menu_cursor = menu_cursor, menu_cursor_style = menu_cursor_style, menu_highlight_style = menu_style, cycle_cursor = True, clear_screen = True ) while not menu_back: menu_sel = menu.show() if menu_sel == 0: chooseWeapon() elif menu_sel == 1: chooseArmor() elif menu_sel == 2: print('going back') menu_back = True
def menu(items, backFunc=exit, preview_command=None, preview_size=0.25, title=None): items.insert(0, '<--') items = [ '{} | {}'.format(item, str(index)) for index, item in enumerate(items) ] terminal_menu = TerminalMenu(items, title, show_search_hint=True, preview_command=preview_command, preview_size=preview_size, clear_screen=True) selected_index = terminal_menu.show() if selected_index == 0: backFunc() if not selected_index: exit() return selected_index - 1
def main(): main_menu_exit = False while not main_menu_exit: print('Seleccione una opcion: ') terminal_menu = TerminalMenu( ["Clima por ciudad", "Clima por coordenadas", "Pronostico por ciudad", "Pronostico por coordenadas", 'Salir']) menu_entry_index = terminal_menu.show() if(menu_entry_index == 0): city = input(str("Ingrese ciudad: ")) data = get_weather(city) show_weather(data) input(menu) elif(menu_entry_index == 1): lat = input("Ingrese latitud: ") lon = input("Ingrese longitud: ") data = get_weather(None, lat, lon) show_weather(data) input(menu) elif(menu_entry_index == 2): city = input(str("Ingrese ciudad: ")) data = get_forecast(city) show_forecast(data) input(menu) elif(menu_entry_index == 3): lat = input("Ingrese latitud: ") lon = input("Ingrese longitud: ") data = get_forecast(None, lat, lon) show_forecast(data) input(menu) elif(menu_entry_index == 4): main_menu_exit = True print("Saliendo")
def _view_test(): """Test function for view""" ar = aruco.Dictionary_get(aruco.DICT_6X6_250) param = aruco.DetectorParameters_create() # fname="../datasets/P2/images/093440.jpg" # ids[4,3,8,9,11] fname = "../datasets/P2/images/093428.jpg" # ids[0,4,5,6,7,9,11] img = cv2.imread(fname) cam = Camera("mobile") cam.read_param() v = View(fname, img, ar, param, 171 / 1000, cam) print(v) print("Show image") cv2.imwrite("../logs/temp.jpg", v.img) tmen = TerminalMenu(['No', 'Yes']) if tmen.show() == 1: print("Showing image") scale_percent = 40 # percent of original size width = int(v.img.shape[1] * scale_percent / 100) height = int(v.img.shape[0] * scale_percent / 100) dim = (width, height) # resize image resized = cv2.resize(v.img, dim, interpolation=cv2.INTER_AREA) cv2.imshow(fname, resized) cv2.waitKey(0) else: print("Did not show menu")
def autodetect_codec(path): if re.search("h.264", path, re.IGNORECASE) != None and ( re.search("blu", path, re.IGNORECASE) != None or re.search("web", path, re.IGNORECASE) == None): return 'h.264 Remux' elif re.search("h.265", path, re.IGNORECASE) != None and ( re.search("blu", path, re.IGNORECASE) != None or re.search("web", path, re.IGNORECASE) == None): return 'x264' elif re.search("x265", path, re.IGNORECASE) != None: return 'x265' elif re.search("x264", path, re.IGNORECASE) != None: return 'x264' elif re.search("VC-1 Remux", path, re.IGNORECASE) != None: return 'VC-1 Remux' elif re.search("MPEG2 Remux", path, re.IGNORECASE) != None: return 'MPEG2 Remux' upstring = f"{os.path.basename(path)}\nWhat is the codec of the Upload?" print(upstring) options = [ "x264", "h.264 Remux", "x265", "h.265 Remux", "VC-1 Remux" "MPEG2 Remux" ] if sys.platform != "win32": menu = TerminalMenu(options) menu_entry_index = menu.show() else: menu_entry_index = SelectionMenu.get_selection(options) value = options[menu_entry_index] return value
def shader(fn, width, height, shader, ten_bit, outname): clear() files = [] if os.path.isdir(fn): for file in glob.glob(os.path.join(fn, "*.mkv")): files.append(os.path.join(file)) else: remove_audio_and_subs(fn) fn = "temp.mkv" clear() cg_menu = TerminalMenu( ["CPU (only x264 4:4:4) - needs to be converted to x265 later with ffmpeg", "GPU (NVENC HEVC/X265 - may result in lower quality than CPU) - NVIDIA ONLY - no conversation necessary" ], title="Choose what to use when encoding after applying shaders." ) cg_choice = cg_menu.show() if cg_choice == 0: cpu_shader(fn, width, height, shader, ten_bit, outname, files=files) elif cg_choice == 1: gpu_shader(fn, width, height, shader, ten_bit, outname, files=files) else: print("Cancel") sys.exit(-2) if os.path.isdir(fn): os.remove("temp.mkv") else: os.remove(fn)
def mainMenu(self): """Menu for the application.""" main_menu_title = "DBA Price predictor for Bang & Olufsen items\n By Casper P\n" main_menu_items = ["Scrape DBA", "Train model", "Predict price", "Quit"] main_menu_cursor = " > " main_menu_cursor_style = ("fg_red", "bold") main_menu_style = ("bg_blue", "fg_yellow") main_menu_exit = False main_menu = TerminalMenu(menu_entries=main_menu_items, title=main_menu_title, menu_cursor=main_menu_cursor, menu_cursor_style=main_menu_cursor_style, menu_highlight_style=main_menu_style, cycle_cursor=True, clear_screen=True) while not main_menu_exit: main_sel = main_menu.show() if main_sel == 0: self.scrape() time.sleep(3) elif main_sel == 1: self.train() elif main_sel == 2: self.trainer.predict() input("Press enter for main menu") elif main_sel == 3: main_menu_exit = True
def build_menu(self, args, items, preview=None, preview_size=0.25): # This function creates a menu. # Parameters: # args: dict with title and optionally cursor, cursor_style, menu_style # itemFunc: a function that populates the menu items # example call: # # sel = self.build_menu({'title': 'Numbers from 1 to 10'}, range(10)) # # Returns: # (item_number, item_text) title = args['title'] cursor = valueOrDefault(args, 'cursor', "> ") cursor_style = valueOrDefault(args, 'cursor_style', ("fg_blue", "bold")) menu_style = valueOrDefault(args, 'menu_style', ("bg_blue", "fg_yellow")) cycle_cursor = valueOrDefault(args, 'cycle_cursor', True) clear_screen = valueOrDefault(args, 'clear_screen', True) menu_exit = False while not menu_exit: self.built_menu = TerminalMenu(menu_entries=items, title=title, menu_cursor=cursor, menu_cursor_style=cursor_style, menu_highlight_style=menu_style, cycle_cursor=cycle_cursor, clear_screen=clear_screen, preview_command=preview, preview_size=preview_size) ret = self.built_menu.show() if ret is None: return ((None, None)) else: return ((ret, items[ret]))
def confirmSelection(): options = buildMenuOptions(["Yes", "No"]) terminal_menu = TerminalMenu( options, title="Do you want to confirm project initialization?") # noqa: E501 menu_entry_index = terminal_menu.show() return scaffold() if menu_entry_index == 1 else True
def encode_to_hevc(fn, out): param_line = "crf=18.0:limit-sao=1:bframes=8:aq-mode=3:psy-rd=1.0" detail_menu = TerminalMenu([ "(Recommended if you dont know) One Setting to rule them all", "(e.g Your Name) Flat, slow anime (slice of life, everything is well lit)", "(e.g Kimetsu no Yaiba) Some dark scene, some battle scene (shonen, historical, etc.)", "(Rarely used) [TV Series] Movie-tier dark scene, complex grain/detail", "(Rarely used) [Movie] Movie-tier dark scene, complex grain/detail", ], title="Choose the encode options") choice = detail_menu.show() # Flat, slow anime (slice of life, everything is well lit) if choice == 1: param_line = "crf=19.0:bframes=8:aq-mode=3:psy-rd=1:aq-strength=0.8:deblock=1,1" #Some dark scene, some battle scene (shonen, historical, etc.) elif choice == 2: param_line = "crf=18.0:bframes=8:aq-mode=3:psy-rd=1.5:psy-rdoq=2" #[TV Series] Movie-tier dark scene, complex grain/detail elif choice == 3: param_line = "crf=18.0:limit-sao=1:bframes=8:aq-mode=3:psy-rd=1.5:psy-rdoq=3.5" #[Movie] Movie-tier dark scene, complex grain/detail elif choice == 4: param_line = "crf=16.0:limit-sao=1:bframes=8:aq-mode=3:psy-rd=1.5:psy-rdoq=3.5" if is_tool("ffmpeg-bar"): binary = "ffmpeg-bar" else: binary = "ffmpeg" files = [] if os.path.isdir(fn): for file in glob.glob(os.path.join(fn, "*.mkv")): files.append(os.path.join(file)) if len(files) == 0: cmd = [ binary, "-hide_banner", "-i", fn, "-c:v", "libx265", "-profile:v", "main10", "-pix_fmt", "yuv420p10le", "-preset", "slow", "-x265-params", param_line, "-map", "0:v:0", "-f", "matroska", '-vf', 'scale=out_color_matrix=bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709', '-colorspace', 'bt709', out ] subprocess.call(cmd) else: for f in files: clear() name = f.split("/") name = name[len(name) - 1] cmd = [ binary, "-hide_banner", "-i", f, "-c:v", "libx265", "-profile:v", "main10", "-pix_fmt", "yuv420p10le", "-preset", "slow", "-x265-params", param_line, "-map", "0:v:0", "-f", "matroska", '-vf', 'scale=out_color_matrix=bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709', '-colorspace', 'bt709', os.path.join(out, name) ] subprocess.call(cmd)
def select_file(): file_select_menu = TerminalMenu(["[1] File 1","[2] File 2","[3] File 3", "[4] File 4","[5] File 5","[6] File 6","[7] File 7","[8] File 8","[9] File 9","[a] File 10", "[b] File 11","[c] File 12","[d] File 13","[e] File 14","[f] File 15","[g] File 16"]) result = file_select_menu.show() selected_save = f"file{result+1}.json" return selected_save
def choose_nb(directory): """ show select menu on command line to pick notebook """ nbs = glob.glob(f"{directory}/*.ipynb") terminal_menu = TerminalMenu(nbs) idx = terminal_menu.show() if idx != None: return Path(nbs[idx])
def __init__(self): '''initialize a search menu''' self.__search_input = {'offset': '0', 'limit': '50'} self.__search_results = {} # getting the api key from key chain self.__api_key = keyring.get_password('realtor', 'realtor') # Run the search menu print( '\n\tUse the search filters to customize your search. You can use City and State in combination or just a Zip Code.' ) print( '\tYou cannot use both at the same time and they are required. The last value you submit from both will take precedence.\n' ) while True: menu = [ '1. City*', '2. State Code*', '3. Zip Code*', '4. Beds Min', '5. Bath Min', '6. Price Max', '7. Submit', '8. Exit' ] terminal_menu = TerminalMenu(menu, title='\nSearch Filters\n') menu_entry_index = terminal_menu.show() # going over the menu choices if menu_entry_index == 0: self.__search_input['city'] = input( '\nEnter the name of the city you wish to search in: ') # if there is a zip value it gets removed from the dict if 'postal_code' in self.__search_input.keys(): del self.__search_input['postal_code'] elif menu_entry_index == 1: self.__search_input['state_code'] = input( '\nEnter the state code you wish to search in: ').upper() # if there is a zip value it gets removed from the dic if 'postal_code' in self.__search_input.keys(): del self.__search_input['postal_code'] elif menu_entry_index == 2: self.__search_input['postal_code'] = input( '\nEnter the zip code you wish to search in: ') # if there is city and state values they get removed form the dict if 'city' in self.__search_input.keys(): del self.__search_input['city'] if 'state_code' in self.__search_input.keys(): del self.__search_input['state_code'] elif menu_entry_index == 3: self.__search_input['beds_min'] = input( '\nEnter minimum number of bedrooms: ') elif menu_entry_index == 4: self.__search_input['baths_min'] = input( '\nEnter minimum number of bathrooms: ') elif menu_entry_index == 5: self.__search_input['price_max'] = input( '\nEnter the maximum price: ') elif menu_entry_index == 6: if self.__submit_search(): df = pd.DataFrame(self.__search_results) print(tabulate(df, headers='keys', tablefmt='psql')) print('\nYou have successfully submitted your search.\n') break elif menu_entry_index == 7: break
def start_app(): print(f"{green_color}starting scripts app{black_color}") print("available apps: ") terminal_options = ['Image detection app', 'teste 2', 'teste 3'] terminal_menu = TerminalMenu(terminal_options) selected_option_index = terminal_menu.show() if selected_option_index == 0: start_color_detection_app()
def printMenu(): try: menuOptionsConfig = menuOptions.optionsMenu menuOptionsTermnial = TerminalMenu(menuOptionsConfig, title="Select one option:") selectionIndex = menuOptionsTermnial.show() selectionMenu(selectionIndex) except ValueError: exceptions.printException(__name__)
def display_title_screen(): terminal_menu = TerminalMenu(["[1] New Game","[2] Load Game","[3] Quit"]) menu_entry_index = terminal_menu.show() if menu_entry_index == 0: start_new_game() elif menu_entry_index == 1: select_file() elif menu_entry_index == 2: quit()
def main(): if os.path.isdir('.git') is False: print('{}: not in a git repo'.format(name)) return branches = os.listdir('.git/refs/heads') terminal_menu = TerminalMenu(branches, 'Checkout branch') result = terminal_menu.show() os.system('git checkout {}'.format(branches[result]))
def preview(*, cli_args: str = None, doc: str = ""): """Select and print commit, show preview of "git show" in full screen.""" global log args = hedgehog.init( _init_preview, arguments=cli_args, logger=True, argp_kwargs=dict( description=doc, usage="%(prog)s [opts] [<revision range>] [[--] <path>...]", ), ) log = logging.getLogger(args.prog_name) log.debug(args) git_args = [ "log", "--oneline", "--decorate", "-n", args.max_count, *args.remainder, ] lines = common.git_command(*git_args).strip().splitlines() commits = [(line, line.split(maxsplit=1)[0]) for line in lines] log.debug_obj(commits, "Commits") def _preview_command(commit_id): if args.log_preview: return common.git_command("log", "-1", commit_id) return common.git_command( "show", "--color={}".format("always" if args.color else "never"), commit_id) menu = TerminalMenu( ("|".join(c) for c in commits), preview_command=_preview_command, cycle_cursor=False, preview_size=0.85, clear_screen=not args.print, show_search_hint=True, ) index = menu.show() if index is None: return log.debug("Selected index: %s, commit: %s", index, commits[index]) if args.print: print(commits[index][1]) return tempfd, tempname = tempfile.mkstemp() subprocess.run(["git", "show", commits[index][1]], text=True, stdout=tempfd, check=True) log.debug("'git show %s' written to %s", commits[index][1], tempname) subprocess.run(["bat", "--language", "Diff", tempname], text=True) os.remove(tempname)
def recursiveNavigation(asset: Asset, prevAsset: Asset or None = None): if prevAsset: prev_asset_stack.append(prevAsset) print( f"\n ~*~*~*~* Viewing {asset.getTag()} ({asset.getUnitOfMeasure()}) Children ~*~*~*~ \n") print(asset.getAssetTable() if asset.assetChildren else "No children to view") while True: options = list(filter(lambda item: item is not None, ["View Children", "View Child Asset" if asset.assetChildren else None, "View Parent Asset" if prevAsset else None, "View Event Log", "Update Event Log", "Exit"])) entry = TerminalMenu(options, title=f"\nWhat would you like to do with {asset.getTag()}?").show() if options[entry] == "View Children": print( f"\n ~*~*~*~* Viewing {asset.getTag()} ({asset.getUnitOfMeasure()}) Children ~*~*~*~ \n") print(asset.getAssetTable()) pass if options[entry] == "Update Event Log": print( f"\nUpdating event log for {asset.getTag()}. \nNOTE: Updates are recursive and will update the event log for all of this assets' children, as well.") event = input( str("Please enter an event (e.g., Lost, Damaged, Arrived at Location, Scan): ")) asset.updateEventLog(event) print("Update success!") pass if options[entry] == "View Event Log": print( f"\n ~*~*~*~* Viewing {asset.getTag()} ({asset.getUnitOfMeasure()}) Event Log ~*~*~*~ \n") print(asset.getEventLogTable()) pass if options[entry] == "View Child Asset": asset_li = asset.getListIterator() asset_li.first() items = [asset_li.next() for i in range(len(asset))] entry = TerminalMenu([i.getTag() for i in items], title="\nWhich child asset would you like to view?").show() assetToView = items[entry] recursiveNavigation(assetToView, asset) break if options[entry] == "View Parent Asset": recursiveNavigation(prev_asset_stack.pop(), prev_asset_stack.pop() if len( prev_asset_stack) > 0 else None) break if options[entry] == "Exit": break
def buildRoute(g: LinkedDirectedGraph): fromVertex = airports[TerminalMenu( airports, title="\nBuild route from...").show()] toVertex = airports[TerminalMenu( airports, title="\nBuild route to...").show()] distance = int( input(f"\nWhat is the distance from {fromVertex} to {toVertex}? Integers only: ")) edge = g.addEdge(fromVertex, toVertex, distance) print(f"\nRoute added: {edge}")
def run_menu(menu_items, settings, header=None, description=None): menu_exit = False menu = TerminalMenu(get_choices(menu_items)) while not menu_exit: pre_menu(settings, header, description) choice = menu.show() menu_exit = handle_choice(menu_items, choice, settings)