def loadRecordings(): global SAFE_MODE_ENABLED global APP clearCanvas() small_font = font.Font(size=5) instruction_select_label = Label(CANVAS, text='Select the file you want to replay', font=('bold', 12)) instruction_select_label.pack() listbox = Listbox(CANVAS) listbox.config(width=60, height=3, font=small_font) listbox.pack() scrollbar = Scrollbar(CANVAS) scrollbar.pack(side=RIGHT, fill=BOTH) listbox.config(yscrollcommand=scrollbar.set) scrollbar.config(command=listbox.yview) findSaveFiles(listbox) if SAFE_MODE_ENABLED: select_button = tk_Button( CANVAS, text='Replay Routine', width=30, height=1, font=('bold', 8), command=lambda: safeReplay(listbox.get(ANCHOR))) select_button.pack() else: select_button = tk_Button(CANVAS, text='Replay Routine', width=30, height=1, font=('bold', 8), command=lambda: replay(listbox.get(ANCHOR))) select_button.pack()
def homeReset(): global CANVAS clearCanvas() TOP_BUTTON = tk_Button(CANVAS, text='RECORD', command=lambda: toggleRecord('0')) #this can be a bit confusing. As soon as you hit record, your inputs are recorded TOP_BUTTON.pack() BOTTOM_BUTTON = tk_Button(CANVAS, text='Replay', command=loadRecordings) #this takes you to more UI BOTTOM_BUTTON.pack() FURTHER_BOTTOM_BUTTON = tk_Button(CANVAS, text='Scheduler', command=scheduleINSTRUCTION) #more UI on this press FURTHER_BOTTOM_BUTTON.pack()
def continuePrompt(button_str): popup = Tk() #ignore this, never called button_str_label = Label(popup, text=button_str, font=('bold', 12)) button_str_label.pack() instruction_label = Label(popup, text='Click continue to proceed with, or exit to abort the sequence', font=('bold', 8)) instruction_label.pack() continue_btn = tk_Button(popup, text='Continue', width=12, command=lambda:setTrue(popup)) #ignore this, would be used to make GUI for SAFE_MODE_ENABLED if you don't want to use microphone continue_btn.pack() exit_btn = tk_Button(popup, text='Exit', width=12, command=lambda:setFalse(popup)) exit_btn.pack() print('Click Continue or Exit') popup.mainloop()
def homeReset(): global CANVAS clearCanvas() TOP_BUTTON = tk_Button(CANVAS, text='RECORD', command=lambda: toggleRecord('0')) TOP_BUTTON.pack() BOTTOM_BUTTON = tk_Button(CANVAS, text='Replay', command=loadRecordings) BOTTOM_BUTTON.pack() FURTHER_BOTTOM_BUTTON = tk_Button(CANVAS, text='Scheduler', command=scheduleINSTRUCTION) FURTHER_BOTTOM_BUTTON.pack()
def __init__(self, filepath, **kwargs): super().__init__(**kwargs) self._filepath = filepath self._paused = False self._time_offset = 0.0 self.grid(row=1, column=0, sticky='NESW') self.rowconfigure(0, minsize=25) self.rowconfigure(2, minsize=25) self.columnconfigure(0, minsize=25) self.columnconfigure(1, minsize=35) self.columnconfigure(2, minsize=50) self.columnconfigure(3, weight=1) self.columnconfigure(4, minsize=50) self._play_button = tk_Button(master=self, anchor='center', text='Play', command=self._play_button_hit) self._play_button.grid(row=1, column=1, sticky='NESW') self._create_time_scale_widgets() self._volume_scale_var = tk_IntVar() self._volume_scale = tk_Scale(master=self, sliderlength=20, from_=100, to=0, variable=self._volume_scale_var, command=self._volume_scale_moved) self._volume_scale.grid(row=0, rowspan=3, column=5) self._volume_scale_var.set(100)
def _init_loading_widgets(self): self._load_filename_entry = tk_Entry(master=self) self._load_filename_entry.grid(row=6, column=1) self._load_button = tk_Button(master=self, text='Load') self._load_button.grid(row=7, column=1) self._load_button.configure(command=self._load_button_command)
def _init_saving_widgets(self): self._save_filename_entry = tk_Entry(master=self) self._save_filename_entry.grid(row=4, column=1) self._save_button = tk_Button(master=self, text='Save') self._save_button.grid(row=5, column=1) self._save_button.configure(command=self._save_button_command)
def toggleRecord(variable): global STOPPER global L_SYS #this function is called when you hit 'Record' on the home screen clearCanvas() TOP_BUTTON = tk_Button(CANVAS, text='STOP', command=lambda: toggleRecord('1')) #now you just have one button, which can call this function again TOP_BUTTON.pack() if variable == '0': beginRecording() #this is what happens when you hit 'Record', you will end up with beginRecording() elif variable == '1': STOPPER = False #whereas, if you've hit 'Stop', you end up here. STOPPER will kill your pynput Listener threads enterFileName() #and now you can save your L_SYS (L system) into a csv file
def enterFileName(): global SAVE_FILE global CANVAS clearCanvas() project_name = StringVar() project_name_label = Label(CANVAS, text='Enter File Name', font=('bold', 12)) project_name_label.pack() project_name_entry = Entry(CANVAS, textvariable=project_name) project_name_entry.pack() #after you stop a recording, you are prompted to enter a filename confirm_save_file_btn = tk_Button(CANVAS, text='Confirm Save File', width=12, command=lambda: saveLsys(project_name.get())) #you can save the file or just hit the home button to discard the recording confirm_save_file_btn.pack()
def continuePrompt(button_str): popup = Tk() button_str_label = Label(popup, text=button_str, font=('bold', 12)) button_str_label.pack() instruction_label = Label( popup, text='Click continue to proceed with, or exit to abort the sequence', font=('bold', 8)) instruction_label.pack() continue_btn = tk_Button(popup, text='Continue', width=12, command=lambda: setTrue(popup)) continue_btn.pack() exit_btn = tk_Button(popup, text='Exit', width=12, command=lambda: setFalse(popup)) exit_btn.pack() print('Click Continue or Exit') popup.mainloop()
def loadRecordings(): global SAFE_MODE_ENABLED global APP clearCanvas() small_font = font.Font(size=5) instruction_select_label = Label(CANVAS, text='Select the file you want to replay', font=('bold', 12)) instruction_select_label.pack() listbox = Listbox(CANVAS) listbox.config(width=60, height=3,font=small_font) #this function is called when you hit 'Replay' on the home screen listbox.pack() scrollbar = Scrollbar(CANVAS) scrollbar.pack(side = RIGHT, fill = BOTH) listbox.config(yscrollcommand = scrollbar.set) scrollbar.config(command = listbox.yview) findSaveFiles(listbox) #all csv files in your directory are loaded if SAFE_MODE_ENABLED: #now we check if you toggled safe mode in the menubar. Go to safe mode if you are replaying someone else's recording select_button = tk_Button(CANVAS, text='Replay Routine', width=30,height=1,font=('bold', 8), command=lambda: safeReplay(listbox.get(ANCHOR))) select_button.pack() #if you toggled safe mode, you get a safe replay of your selected csv file when you hit the button else: select_button = tk_Button(CANVAS, text='Replay Routine', width=30,height=1,font=('bold', 8), command=lambda: replay(listbox.get(ANCHOR))) select_button.pack() #if you didn't toggle safe mode, you get a fairly exact replay of the sequence you recorded. Fast, risky, especially if its not your recording youre replaying
def toggleRecord(variable): global STOPPER global L_SYS clearCanvas() TOP_BUTTON = tk_Button(CANVAS, text='STOP', command=lambda: toggleRecord('1')) TOP_BUTTON.pack() if variable == '0': beginRecording() elif variable == '1': STOPPER = False enterFileName()
def loadEditScreen(): global CANVAS clearCanvas() small_font = font.Font(size=5) instruction_select_label = Label(CANVAS, text='Select the file you want to edit', font=('bold', 12)) instruction_select_label.pack() listbox = Listbox(CANVAS) listbox.config(width=60, height=3,font=small_font) listbox.pack() #some simple GUI here where you can select a file to be sped up on replay scrollbar = Scrollbar(CANVAS) scrollbar.pack(side = RIGHT, fill = BOTH) listbox.config(yscrollcommand = scrollbar.set) scrollbar.config(command = listbox.yview) findSaveFiles(listbox) #fills out the listbox select_button = tk_Button(CANVAS, text='Replay Routine', width=30,height=1,font=('bold', 8), command=lambda: replayEdit(listbox.get(ANCHOR))) #execution here select_button.pack()
def _init_creation_buttons(self): self._creation_button = dict() self._creation_game_objects = [ 'Player', 'BasicPlatform', 'SpeedUpBuff', 'JumpHeightUpBuff' ] for i in range(len(self._creation_game_objects)): self._creation_button[self._creation_game_objects[i]] = tk_Button( master=self, text=self._creation_game_objects[i]) self._creation_button[self._creation_game_objects[i]].grid( row=i, column=1) self._creation_button[self._creation_game_objects[i]].configure( command=self._get_creation_button_command( self._creation_game_objects[i])) self._creation_button['Player'].configure(relief='sunken')
def schedulerScreen(csv): global CANVAS clearCanvas() loop_time = StringVar() loop_time_label = Label(CANVAS, text='Enter Time in Seconds', font=('bold', 8)) loop_time_label.pack() loop_time_entry = Entry(CANVAS, textvariable=loop_time) loop_time_entry.pack() loop_num = StringVar() loop_num_label = Label(CANVAS, text='Enter # of Loops', font=('bold', 8)) #simple GUI loop_num_label.pack() loop_num_entry = Entry(CANVAS, textvariable=loop_num) loop_num_entry.pack() confirm_loop_btn = tk_Button(CANVAS, text='Confirm Loop', width=12, command=lambda: job(csv,loop_time.get(),loop_num.get())) #execution here confirm_loop_btn.pack()
def enterFileName(): global SAVE_FILE global CANVAS clearCanvas() project_name = StringVar() project_name_label = Label(CANVAS, text='Enter File Name', font=('bold', 12)) project_name_label.pack() project_name_entry = Entry(CANVAS, textvariable=project_name) project_name_entry.pack() confirm_save_file_btn = tk_Button( CANVAS, text='Confirm Save File', width=12, command=lambda: saveLsys(project_name.get())) confirm_save_file_btn.pack()
def scheduleINSTRUCTION(): global CANVAS global APP clearCanvas() small_font = font.Font(size=5) instruction_select_label = Label(CANVAS, text='Select the file you want to schedule', font=('bold', 12)) instruction_select_label.pack() listbox = Listbox(CANVAS) listbox.config(width=60, height=3,font=small_font) listbox.pack() #simple GUI scrollbar = Scrollbar(CANVAS) scrollbar.pack(side = RIGHT, fill = BOTH) listbox.config(yscrollcommand = scrollbar.set) scrollbar.config(command = listbox.yview) findSaveFiles(listbox) select_button = tk_Button(CANVAS, text='Schedule Routine', width=30,height=1,font=('bold', 8), command=lambda: schedulerScreen(listbox.get(ANCHOR))) #execution here select_button.pack()