def save_settings(settings_file, settings, values): if values: # if there are stuff specified by another window, fill in those values for key in SETTINGS_KEYS_TO_ELEMENT_KEYS: # update window with the values read from settings file try: settings[key] = values[SETTINGS_KEYS_TO_ELEMENT_KEYS[key]] except Exception as e: print( f'Problem updating settings from window values. Key = {key}' ) with open(settings_file, 'w') as f: jsondump(settings, f) sg.popup('Settings saved')
def __manage(self): date_list = sg.popup_get_date() find_date = date(date_list[2], date_list[0], date_list[1]) if not (find_date in self.undone_tasks_): sg.popup("No tasks at this date!") return current_tasks = self.undone_tasks_[find_date] is_open = False while True: if len(current_tasks) == 0: del self.undone_tasks_[find_date] sg.popup("No tasks left for today!") if is_open: window.close() return layout = [[sg.Text("Tasks for " + str(find_date))]] i = 0 for task in current_tasks: i += 1 temp = [ sg.Text(str(i) + ")"), sg.Text(task.title_, font=tkinter.font.ITALIC), sg.Text("Is frog? ") ] if task.is_frog_: temp.append(sg.Text("Yes", text_color='#00FF00')) else: temp.append(sg.Text("No", text_color='#FF0000')) temp.append(sg.Button("Delete", key=i)) layout.append(temp) layout.append([sg.Button("Return")]) window = sg.Window("Manage", layout) is_open = True event, value = window.read() if event == "Return" or sg.WIN_CLOSED: window.close() return print(event) if 1 <= event <= len(current_tasks): self.undone_tasks_[find_date].pop(event - 1) sg.popup("Task was successfully deleted.") window.close() is_open = False continue
def __current(self): current_index = 0 is_open = False while True: today = date.today() frogs = [] usual = [] if not (today in self.undone_tasks_): sg.popup( "Hooray! No tasks for today! You can chill and enjoy your life." ) if is_open: window.close() break for i in range(current_index, len(self.undone_tasks_[today])): x = self.undone_tasks_[today][i] if x.is_frog_: frogs.append(x) else: usual.append(x) for i in range(0, current_index): x = self.undone_tasks_[today][i] if x.is_frog_: frogs.append(x) else: usual.append(x) undone_amount = len(frogs) + len(usual) all_amount = undone_amount + (len(self.done_tasks_[today]) if (today in self.done_tasks_) else 0) layout = [[sg.Text("Today is " + str(today))]] if undone_amount == 0: sg.popup("Congratulations! You have done all tasks for today!") if is_open: window.close() break else: layout.append([ sg.Text( f'You have completed {all_amount - undone_amount} from {all_amount} tasks today.' f' Good work!') ]) if len(frogs) > 0: current_task = frogs[len(frogs) - 1] else: current_task = usual[len(usual) - 1] layout.append([sg.Text("Current task:")]) layout.append( [sg.Text(current_task.title_, font=tkinter.font.ITALIC)]) layout.append([sg.Text("Is frog?")]) # print("Is frog?", emoji.emojize(':frog:'), end="") if current_task.is_frog_: layout.append([sg.Text("Yes", text_color='#00FF00')]) else: layout.append([sg.Text("No", text_color='#FF0000')]) layout.append([sg.Button("Done")]) layout.append([sg.Button("Skip")]) layout.append([sg.Button("Return")]) window = sg.Window("Current wokflow", layout, resizable=True) is_open = True event, value = window.read() if event == "Done": if not (today in self.done_tasks_): self.done_tasks_[today] = [] self.done_tasks_[today].append(current_task) self.undone_tasks_[today].remove(current_task) if not self.undone_tasks_[today]: del self.undone_tasks_[today] window.close() is_open = False continue if event == "Skip": if current_task.is_frog_: sg.popup("You can't skip the frog!") window.close() continue current_index += 1 current_index %= len(self.undone_tasks_[today]) is_open = False window.close() continue if event == "Return" or event == sg.WIN_CLOSED: window.close() is_open = False break
|_| \___/| .__/ \__,_| .__/ |_| |_| A Popup demonstration. A "Popup" window is shown over the main window. Clicking OK will close the Popup and you return to main again. """ print('Starting up...') layout = [[ sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_') ], [sg.Input('', key='_IN_')], [sg.Button('Show'), sg.Button('Exit'), sg.Button('Blank')]] window = sg.Window('Window Title', layout) while True: # Event Loop print('in event loop') event, values = window.read() print(event, values) if event in (None, 'Exit'): break if event == 'Show': sg.popup('A popup!', ' You typed ', values['_IN_']) window.close()
size=(5, 20), default_value=75), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), sg.Column(column1, background_color='#F7F3EC') ]]) ], [sg.Text('_' * 80)], [sg.Text('Choose A Folder', size=(35, 1))], [ sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse() ], [sg.Submit(tooltip='Click to submit this window'), sg.Cancel()] ] window = sg.Window('Everything bagel', layout, default_element_size=(40, 1), grab_anywhere=False) event, values = window.read() window.close() sg.popup('Title', 'The results of the window.', 'The button clicked was "{}"'.format(event), 'The values are', values)
try: proj.IsRenderingInProgress() except TypeError: proj = pm.CreateProject(f"{datetime.datetime.now():%Y%m%d_%H%M%S_}" + 'Transcode') mp = proj.GetMediaPool() # Above is needed to check if 'proj' is accessible, before checking rendering is in progress, # otherwise Resolve will raise an error if proj.IsRenderingInProgress(): sg.Popup('Resolve still rendering, go grab a coffee.') else: watch_path = values['WATCHPATH'] source_folders = values['SOURCEPATHS'] for source_folder in source_folders: # Avoid overwriting. if values['OUTPUTPATH'] == os.path.join(watch_path, source_folder): sg.popup('Output path is same to the source path for:\n\n' + latest_output_path) elif not os.path.exists(os.path.join(watch_path, source_folder)): sg.Popup('Source path error, please check!') window['WATCHPATH'](text_color='red') else: # Try to import timeline, if Resolve project is switched or closed, will get 'False', # then create a new project named '%timestamp%_Transcode'. if not import_timeline(values['WATCHPATH'], source_folder): proj = pm.CreateProject(f"{datetime.datetime.now():%Y%m%d_%H%M%S_}" + 'Transcode') mp = proj.GetMediaPool() import_timeline(watch_path, source_folder) try: queue_render(values['RENDERPRESET'][0], os.path.join(watch_path, source_folder)) except IndexError: sg.Popup('Please select a render preset.')