def edit_joy(): global config menu = qprompt.Menu() for x, y in Header.axis_x.subcon.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['axis_x'] == y: dft = str(x) config[0]['axis_x'] = int(menu.show(msg="Axis-X", dft=dft)) menu = qprompt.Menu() config[0]['x_up'] = \ qprompt.ask_int("X-Up", dft=config[0]['x_up']) config[0]['x_down'] = \ qprompt.ask_int("X-Down", dft=config[0]['x_down']) for x, y in Header.axis_y.subcon.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['axis_y'] == y: dft = str(x) config[0]['axis_y'] = int(menu.show(msg="Axis-Y", dft=dft)) config[0]['y_up'] = \ qprompt.ask_int("Y-Up", dft=config[0]['y_up']) config[0]['y_down'] = \ qprompt.ask_int("Y-Down", dft=config[0]['y_down'])
def edit_joy(): global config if config[0]['mk2']: Header = Header_Mk2 else: quit("Unable to configure Joystick on MK1 configuration, convert " \ "to MK2 and try again") menu = qprompt.Menu() for x, y in Header.axis_x.subcon.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['axis_x'] == y: dft = str(x) config[0]['axis_x'] = int(menu.show(msg="Axis-X", dft=dft)) menu = qprompt.Menu() config[0]['x_up'] = \ qprompt.ask_int("X-Up", dft=config[0]['x_up']) config[0]['x_down'] = \ qprompt.ask_int("X-Down", dft=config[0]['x_down']) for x, y in Header.axis_y.subcon.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['axis_y'] == y: dft = str(x) config[0]['axis_y'] = int(menu.show(msg="Axis-Y", dft=dft)) config[0]['y_up'] = \ qprompt.ask_int("Y-Up", dft=config[0]['y_up']) config[0]['y_down'] = \ qprompt.ask_int("Y-Down", dft=config[0]['y_down'])
def edit_pad(pad): global config bank = int((pad - 1) / _PADS) subpad = pad - (_PADS * bank) - 1 menu = qprompt.Menu() for x, y in Pad.type.subcon.ksymapping.items(): menu.add(str(x), y) if config[1][bank][subpad]['type'] == y: dft = str(x) ptype = menu.show(hdr="Pad %d (Bank %s-%d):" % (pad, chr(65 + bank), subpad + 1), msg="Type", dft=dft) config[1][bank][subpad]['type'] = int(ptype) config[1][bank][subpad]['channel'] = \ qprompt.ask_int("Channel", vld=list(range(1,17)), dft=config[1][bank][subpad]['channel']) if ptype == '0': config[1][bank][subpad]['note'] = \ qprompt.ask_int("Note", vld=list(range(0,128)), dft=config[1][bank][subpad]['note']) menu = qprompt.Menu() for x, y in Pad.trigger.subcon.ksymapping.items(): menu.add(str(x), y) if config[1][bank][subpad]['trigger'] == y: dft = str(x) config[1][bank][subpad]['trigger'] = int( menu.show(msg="Trigger", dft=dft)) menu = qprompt.Menu() for x, y in Pad.aftertouch.subcon.ksymapping.items(): menu.add(str(x), y) if config[1][bank][subpad]['aftertouch'] == y: dft = str(x) config[1][bank][subpad]['aftertouch'] = int( menu.show(msg="Aftertouch", dft=dft)) elif ptype == '1': config[1][bank][subpad]['program'] = \ qprompt.ask_int("Program", vld=list(range(0,128)), dft=config[1][bank][subpad]['program']) else: config[1][bank][subpad]['msb'] = \ qprompt.ask_int("MSB", vld=list(range(0,128)), dft=config[1][bank][subpad]['msb']) config[1][bank][subpad]['lsb'] = \ qprompt.ask_int("LSB", vld=list(range(0,128)), dft=config[1][bank][subpad]['lsb'])
def edit_general(): global config config[0]['channel'] = \ qprompt.ask_int("Midi Ch for Keys", dft=config[0]['channel']) menu = qprompt.Menu() for x, y in Header.octave.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['octave'] == y: dft = str(x) config[0]['octave'] = int(menu.show(msg="Keyboard Octave", dft=dft)) menu = qprompt.Menu()
def jakoby_1(): print(120 * "-") print("You have entered door number 2.") print("There are four berserkers who turn to look at you with hatred in their eyes. ") print("You look down and see you have your 3.335 inch Wilson Rapid Response Folding Knife in your hand, with nothing else.") print("One of the berserkers roars, in a terrifyingly loud voice. \nThen everyone moves to attack.") print("What do you do?") print(120 * "-") berserker_options = [ 'Slash the knees', 'Punch and slash their faces', 'Drive the knife into their mouths', 'Run' ] menu = qprompt.Menu() for i, item in enumerate(berserker_options): menu.add(str(i + 1), item) berserker_options_choice = menu.show() if berserker_options_choice == "1": dead("The berserker fell to one knee, but then punches you so hard that your sternum collapses into your heart, killing you instantly.") elif berserker_options_choice == "2": dead("The berserker's masks protect their faces from any blade or impact. They easily knock it off then tear off your arms.") elif berserker_options_choice == "3": heaven() elif berserker_options_choice == "4": start() else: jakoby_1()
def enter(self): print(120 * "-") print( dedent(""" You and Saphira have successfully escaped back into the air above the forest. Saphira turns around and goes back to the starting point, where you have the options to go to the North West, North, North East, or far to the North. """)) print(120 * "-") prompt_start = ['North West', 'North', 'North East', 'Far North'] menu = qprompt.Menu() for i, item in enumerate(prompt_start): menu.add(str(i + 1), item) prompt_start_choice = menu.show() if prompt_start_choice == "1": return 'elves' elif prompt_start_choice == "2": return 'trolls' elif prompt_start_choice == "3": return 'paradise' elif prompt_start_choice == "4": return 'dragon' else: return 'saphira'
def new_config(): """Prompt user for config variables and generate new config. Returns: A new ConfigDict. """ config = ConfigDict() config["module-path"] = qprompt.ask_str("Top-level module path", blk=False, vld=os.path.exists, hlp=MODULE_PATH_HELP) timeout = qprompt.ask_str( "Test execution timeout (seconds)", vld=float, blk=False, hlp="The number of seconds to let a test run before terminating it.", ) config["timeout"] = float(timeout) config["excluded-modules"] = [] config["test-command"] = qprompt.ask_str("Test command", blk=False, hlp=TEST_COMMAND_HELP) menu = qprompt.Menu() for at_pos, distributor_name in enumerate(distributor_names()): menu.add(str(at_pos), distributor_name) config["distributor"] = ConfigDict() config["distributor"]["name"] = menu.show(header="Distributor", returns="desc") return config
def edit_general(): global config config[0]['channel'] = \ qprompt.ask_int("Midi Ch for Keys", dft=config[0]['channel']) menu = qprompt.Menu()
def main_menu(self): def start(swap=False): p = PracticeConfig(swap=swap, **related.to_dict(self.config)) trycatch(Practice(p).start, rethrow=DEBUG_MODE)() def learn(): p = PracticeConfig(swap=False, **related.to_dict(self.config)) trycatch(Practice(p).learn, rethrow=DEBUG_MODE)() menu = q.Menu() menu.add( "1", f"{self.config.lang1.name.full} to {self.config.lang2.name.full}", start, [False]) menu.add( "2", f"{self.config.lang2.name.full} to {self.config.lang1.name.full}", start, [True]) menu.add("l", "Learn vocab", learn) menu.add("d", "Delete missed vocab", delete, [op.join(self.config.path, MISSED_VOCAB)]) menu.add("c", "Count vocab", count, [self.config.path]) menu.add("a", "Sort all files", sort_all, [self.config.path]) menu.add("s", "Settings", trycatch(self.settings_menu)) menu.main(loop=True)
def new_config(): """Prompt user for config variables and generate new config. Returns: A new ConfigDict. """ config = ConfigDict() config["module-path"] = qprompt.ask_str("Top-level module path") python_version = qprompt.ask_str( 'Python version (blank for auto detection)') config['python-version'] = python_version timeout = qprompt.ask_str('Test execution timeout (seconds)') config['timeout'] = float(timeout) config['excluded-modules'] = [] config["test-command"] = qprompt.ask_str("Test command") menu = qprompt.Menu() for at_pos, engine_name in enumerate(execution_engine_names()): menu.add(str(at_pos), engine_name) config["execution-engine"] = ConfigDict() config['execution-engine']['name'] = menu.show(header="Execution engine", returns="desc") return config
def amirah_0(): print(120 * "-") print(""" You have entered door number 1. When you enter, you smell something that makes you freeze in place. It smells like rotting meat for some reason. Then you look around and see... zombies infected with the Seif Al Din are all around you. Hundreds of them. But then you look down and see that you have a M4 Carbine with 4 extra magazines, a 9mm Beretta, and your 3.335 inch Wilson Rapid Response Folding Knife. What do you do?""") print(120 * "-") zombie_options = [ 'Full automatic fire, aiming for body shots', 'Save the infected people', 'Semi automatic fire, aiming for headshots only', 'Run away' ] menu = qprompt.Menu() for i, item in enumerate(zombie_options): menu.add(str(i + 1), item) zombie_options_choice = menu.show() if zombie_options_choice == "1": dead("The zombies staggered, but did not fall. They surround you and tear your throat out.\n") elif zombie_options_choice == "2": dead("By putting your guard down and hesitating, the zombies launch on you and tear your throat out.\n") elif zombie_options_choice == "3": heaven() else: start()
def start(): print(120 * "-") print("You materialize in the middle of a circular chamber. You can hear very loud thunder booming way overhead.") print("You have the feeling that you have just entered into hell.") print("You look around, and realize there are 4 doors spaced evenly around the circular chamber. ") print(120 * "-") door_options = [ '1', '2', '3', '4', ] menu = qprompt.Menu() for i, item in enumerate(door_options): menu.add(str(i + 1), item) choice = menu.show() if choice == "1": amirah_0() elif choice == "2": jakoby_1() elif choice == "3": gault_2() elif choice == "4": upier_3() else: start()
def enter(self): print(120 * "-") print( dedent(""" You and Saphira fly down into a valley next to a mountain. Everything is still, except for a slight breeze rustling the trees. All of a sudden, you feel your mind start to be penetrated by a weird consciousness. What do you do? """)) print(120 * "-") prompt_dragons = [ 'Protect your barriers and fly away', 'Fight back with the Eldunari and Saphira\'s mind', 'Say that you are a friend in the ancient language' ] menu = qprompt.Menu() for i, item in enumerate(prompt_dragons): menu.add(str(i + 1), item) prompt_dragons_choice = menu.show() if prompt_dragons_choice == "1": print(120 * "-") print( dedent(""" Saphira immediately flys off above the forest, scared of the power of the consciousness. """)) print(120 * "-") return 'saphira' elif prompt_dragons_choice == "2": print(120 * "-") print( dedent(""" The Eldunari, Saphira, and you push with all your might against the consciousness. Eventually, the consciousness pushes back with such ferocity, that it destroys all three of your barriers. A voice then speaks in your mind, saying,\n \"Welcome Eragon and Saphira, we have been expecting you.\" """)) print(120 * "-") return 'finished' elif prompt_dragons_choice == "3": print(120 * "-") print( dedent(""" Eragon quickly shouts that he is a friend and rider, looking for a new haven. A voice then speaks in his mind, saying\n \"Welcome Eragon and Saphira, we have been expecting you.\" """))
def sortMenu(): #submenu for choosing sort type menu = qprompt.Menu() menu.add("1", "Sort by website", sortWebsite ) #params -> selection key, label, function to call once selected menu.add("2", "Sort by Username", sortUsername) menu.add("3", "List all passwords", listAll) menu.add("9", "Go back", mainMenu) menu.add("0", "Quit", exit) choice = menu.show(header="SORTING")
def edit_division(): global config menu = qprompt.Menu() for x, y in Header.division.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['division'] == y: dft = str(x) config[0]['division'] = int(menu.show(msg="Division", dft=dft))
def edit_swing(): global config menu = qprompt.Menu() for x, y in Header.swing.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['swing'] == y: dft = str(x) config[0]['swing'] = int(menu.show(msg="Swing", dft=dft))
def set_threshold(r): menu = qprompt.Menu() menu.add("o", "Otsu thresholding") menu.add("i", "Isodata thresholding") menu.add("e", "Lee thresholding") menu.add("l", "Local thresholding (slow)", local_threshold_prompt, [r]) menu.add("q", "Quit") while menu.show(header = "Threshold Menu") != "q": pass
def edit_transpose(): global config menu = qprompt.Menu() for x, y in Header.transpose.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['transpose'] == y: dft = str(x) config[0]['transpose'] = int(menu.show(msg="Transpose", dft=dft))
def edit_arpeggio(): global config if config[0]['mk2']: menu = qprompt.Menu() for x, y in Header.enable.subcon.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['enable'] == y: dft = str(x) config[0]['enable'] = int(menu.show(msg="Enable", dft=dft)) menu = qprompt.Menu() for x, y in Header.division.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['division'] == y: dft = str(x) config[0]['division'] = int(menu.show(msg="Division", dft=dft)) menu = qprompt.Menu() for x, y in Header.mode.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['mode'] == y: dft = str(x) config[0]['mode'] = int(menu.show(msg="Mode", dft=dft)) menu = qprompt.Menu() for x, y in Header.latch.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['latch'] == y: dft = str(x) config[0]['latch'] = int(menu.show(msg="Latch", dft=dft)) menu = qprompt.Menu() for x, y in Header.octaves.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['octaves'] == y: dft = str(x) config[0]['octaves'] = int(menu.show(msg="Octaves", dft=dft)) menu = qprompt.Menu() for x, y in Header.swing.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['swing'] == y: dft = str(x) config[0]['swing'] = int(menu.show(msg="Swing", dft=dft)) config[0]['taps'] = \ qprompt.ask_int("Taps", vld=list(range(2,4)), dft=config[0]['taps']) config[0]['tempo'] = \ qprompt.ask_int("Tempo", dft=config[0]['tempo']) menu = qprompt.Menu() for x, y in Header.clock.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['clock'] == y: dft = str(x) config[0]['clock'] = int(menu.show(msg="Clock", dft=dft))
def get_choice(vecs): menu = qprompt.Menu() for vec in vecs: menu.add(vec["short_name"], vec['vec']) choice = menu.show(returns="desc") key_phrase = '' if choice != generic_vec_name: while key_phrase == '': key_phrase = qprompt.ask_str("enter key phrase: ") return choice, key_phrase.lower()
def mainMenu(): #main menu for function types menu = qprompt.Menu() menu.add("1", "Search by website", searchByWebsite) menu.add("2", "Search by username", searchByUsername) menu.add("3", "Add password", addPass) menu.add("4", "Remove password", delPass) menu.add("5", "Edit Password", updatePass) menu.add("6", "Sort By...", sortMenu) menu.add("0", "Quit", exit) choice = menu.show()
def edit_pad(pad): global config bank = int((pad - 1) / _PADS) subpad = pad - (_PADS * bank) - 1 config[1][bank][subpad]['note'] = \ qprompt.ask_int("Note", vld=list(range(0,128)), dft=config[1][bank][subpad]['note']) menu = qprompt.Menu()
def new_config(): """Prompt user for config variables and generate new config. Returns: A new configuration as a single string. """ conf = {'module': qprompt.ask_str("Top-level module")} menu = qprompt.Menu() test_runners = test_runner_names() for at_pos, test_runner in enumerate(test_runners): menu.add(str(at_pos), test_runner) conf['test_runner'] = menu.show(header="Test runner", returns="desc") conf['test_args'] = qprompt.ask_str('Test args') menu = qprompt.Menu() for at_pos, engine_name in enumerate(execution_engine_names()): menu.add(str(at_pos), engine_name) conf['engine'] = menu.show(header="Execution engine", returns="desc") return TEMPLATE.format(**conf)
def create_menu(self): """ Creates a qprompt menu and adds all items from config :return: qprompt menu """ menu = qprompt.Menu() for i, item in enumerate(self.config['user']): menu.add(str(i+1), item) menu.add("0", "Exit") menu.add("-1", "List settings") menu.add("-2", "Reset config") return menu
def __init__(self, opts_assign: dict): self.opts = opts_assign self.invoke_menus = { self.MENU_MAIN: self.show_main_menu, self.MENU_CREATE_USER: self.show_create_user_menu } self.username, self.password = '', '' self.login_status = (False, '') self.main_menu = qprompt.Menu() # init methods self.create_menus()
def edit_general(): global config if config[0]['mk2']: Header = Header_Mk2 else: Header = Header_Mk1 config[0]['pchannel'] = \ qprompt.ask_int("Midi Ch for Pads", dft=config[0]['pchannel']) config[0]['dchannel'] = \ qprompt.ask_int("Midi Ch for Dials/Keys", dft=config[0]['dchannel']) menu = qprompt.Menu() for x, y in Header.octave.subcon.ksymapping.items(): menu.add(str(x), y) if config[0]['octave'] == y: dft = str(x) config[0]['octave'] = int(menu.show(msg="Keyboard Octave", dft=dft)) menu = qprompt.Menu()
def edit_scale(pad, verbose): global config rbank = int((pad - 1) / _PADS) rsubpad = pad - (_PADS * rbank) - 1 menu = qprompt.Menu() x = 0 for y in Scale._SCALE_PATTERNS: menu.add(str(x), y) x = x + 1 stype = menu.show(hdr="Pad %d (Bank %s-%d):" % (pad, chr(65 + rbank), rsubpad + 1), msg="Scale", returns="desc") root = qprompt.ask_int("Note", vld=list(range(0, 128)), dft=config[1][rbank][rsubpad]['note']) count = qprompt.ask_int("Count", vld=[0] + list(range(1, _PTOTAL + 2 - pad)), dft=0) scale = Scale.build_scale(Note.from_midi_num(root), stype) scale_lst = [] for note in scale: scale_lst.append(note.midi_note_number()) if count: while len(scale_lst) < count: root = scale_lst.pop() scale = Scale.build_scale(Note.from_midi_num(root), stype) for note in scale: scale_lst.append(note.midi_note_number()) else: count = len(scale_lst) if pad + count > _PTOTAL: count = _PTOTAL + 1 - pad for note in scale_lst[:count]: bank = int((pad - 1) / _PADS) subpad = pad - (_PADS * bank) - 1 config[1][bank][subpad]['note'] = note if verbose: print("Setting Pad %d (Bank %s-%d) to %d (%s)" % (pad, chr(65 + bank), subpad + 1, note, Note.from_midi_num(note))) pad = pad + 1
def edit_sound(): global config menu = qprompt.Menu() ''' for x,y in Sounds.keys.subcon.subcon.ksymapping.items(): menu.add(str(x),y) if config[4]['keys'] == y: dft = str(x) config[4]['keys'] = int(menu.show(msg="Key Sound", dft=dft)) ''' config[4]['keys'] = \ qprompt.ask_int("Key Sound", vld=list(range(0,128)), dft=config[4]['keys']) ''' for x,y in Sounds.drums.subcon.subcon.ksymapping.items(): menu.add(str(x),y) if config[4]['drums'] == y: dft = str(x) config[4]['drums'] = int(menu.show(msg="Drum Sound", dft=dft)) ''' config[4]['drums'] = \ qprompt.ask_int("Drum Sound", vld=list(range(0,10)), dft=config[4]['drums']) config[4]['filter'] = \ qprompt.ask_int("Filter", vld=list(range(0,128)), dft=config[4]['filter']) config[4]['res'] = \ qprompt.ask_int("Resonence", vld=list(range(0,128)), dft=config[4]['res']) config[4]['reverb'] = \ qprompt.ask_int("Reverb", vld=list(range(0,128)), dft=config[4]['reverb']) config[4]['chorus'] = \ qprompt.ask_int("Chorus", vld=list(range(0,128)), dft=config[4]['chorus']) config[4]['attack'] = \ qprompt.ask_int("Attack", vld=list(range(0,128)), dft=config[4]['attack']) config[4]['release'] = \ qprompt.ask_int("Release", vld=list(range(0,128)), dft=config[4]['release']) config[4]['eq_low'] = \ qprompt.ask_int("EQ Low", vld=list(range(0,128)), dft=config[4]['eq_low']) config[4]['eq_high'] = \ qprompt.ask_int("EQ High", vld=list(range(0,128)), dft=config[4]['eq_high'])
def new_config(): """Prompt user for config variables and generate new config. Returns: A new ConfigDict. """ config = ConfigDict() config["module-path"] = qprompt.ask_str("Top-level module path", blk=False, vld=os.path.exists, hlp=MODULE_PATH_HELP) python_version = qprompt.ask_str( 'Python version (blank for auto detection)', vld=_validate_python_version, hlp=PYTHON_VERSION_HELP) config['python-version'] = python_version timeout = qprompt.ask_str( 'Test execution timeout (seconds)', vld=float, blk=False, hlp="The number of seconds to let a test run before terminating it.") config['timeout'] = float(timeout) config['excluded-modules'] = [] config["test-command"] = qprompt.ask_str("Test command", blk=False, hlp=TEST_COMMAND_HELP) menu = qprompt.Menu() for at_pos, engine_name in enumerate(execution_engine_names()): menu.add(str(at_pos), engine_name) config["execution-engine"] = ConfigDict() config['execution-engine']['name'] = menu.show(header="Execution engine", returns="desc") config["cloning"] = ConfigDict() config['cloning']['method'] = 'copy' config['cloning']['commands'] = [] config['interceptors'] = ConfigDict() config['interceptors']['enabled'] = [ 'spor', 'pragma_no_mutate', 'operators-filter' ] config['operators-filter'] = ConfigDict() config['operators-filter']['exclude-operators'] = None return config
def ticket_menu(id, flaw): """ Print the ticket and the menu :return choice """ cyan("Editing ticket: ", end="") print(str(id)) # print(flaw) menu = qprompt.Menu() menu.add("e", "Edit") menu.add("p", "Previous") menu.add("n", "Next") menu.add("s", "Save") menu.add("q", "Quit") return menu.show()