def bin(inicio, valor): sg.theme("DarkBlue2") colun = [sg.MLine(inicio)] layout = [[sg.MLine(inicio, size=(70, 3))], [sg.MLine(valor, size=(70, 15))], [sg.Ok(), sg.Button('Voltar')]] Windows = sg.Window('Janela 3', layout=layout) return Windows
def get_layout(): layout = [ [ sg.Text('Selecione o Seus Código'), sg.InputText(), sg.FileBrowse( 'Selecione', file_types=( ( 'Códigos Python', '*.py' ), # Lista não funciona apenas tupla ) ) ], [ sg.Text('Selecione a Lista de destinatário'), sg.Combo(lista, default_value=lista[1]) ], [ sg.Text('Insira o Título'), sg.InputText(key='-Title-') ], [ sg.Text('Insira o Conteudo do Email'), sg.MLine(key='-Content-') ], [ sg.Button('Enviar', key='-Send-'), sg.Button('Gerenciar Lista', key='-ListEditor-') ] ], return layout
def show(self): """ docstring """ image_path = os.path.join(os.getcwd(), "assets/mai.png") print(os.getcwd()) layout = [ [sg.Text("これは PySimpleGUI を使ったサンプルプログラムです.")], [sg.Image(filename=image_path, key="-IMAGE-")], [ sg.Listbox(**self.__list_box_style), sg.VerticalSeparator(), sg.MLine(default_text="A second multi-line", size=(35, 3)), ], [sg.Button("Quit", size=(15, 1)), sg.Button("OK", size=(15, 1))], ] window = sg.Window("Hello Python", layout) # イベントループ window.Resizable = True window.read(timeout=1) window["-NameList-"].expand(expand_x=True, expand_y=True) window["-IMAGE-"].expand(expand_x=True, expand_y=True) while True: event, values = window.read() # イベントの読み取り(イベント待ち) print("イベント:", event, "、値:", values) # 確認表示 if event in (None, "Quit"): print("終了します") break # 終了処理 window.close()
def newGUI(): layout = [ [sg.Text('Text'), sg.Input('Name'), sg.Button('Button1')], [sg.MLine('Multiple Input', size=(30,5)) ], [ sg.Slider(range(0,100), orientation='v', size=(7,15), default_value=40), sg.Slider(range(0, 100), orientation='h', size=(11, 15), default_value=40) ], [sg.Image(r'/Volumes/G-DRIVE mobile SSD R-Series/Shoes/Web saytlar/newkamuelshoes/pythongui_trial/PySimpleGUI_Logo_320.gif')] ] # Create the Window window = sg.Window('Window Title', layout) # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event in ('Exit', None): # if user closes window or clicks cancel break print( event, values[0]) if event == 'Ok': print(values) window.close()
def buildWindow(): ofile_tip = 'Full path to the INPUT file.' dfile_tip = 'Full path to the OURPUR file.' layout = [ [sg.Text('PDF Reverse file')], [ sg.Text('Original File: '), sg.InputText(size=(40, 1), key='-OFILE-', default_text=path_source, enable_events=False, tooltip=ofile_tip) ], [ sg.Text('Dest File: '), sg.InputText(size=(40, 1), key='-DFILE-', default_text=pathDest, enable_events=False, tooltip=dfile_tip) ], [sg.Text('Page: '), sg.Text(size=(9, 1), key='-PAGENO-')], [sg.Text('Number of Pages: '), sg.Text(size=(9, 1), key='-NUMPAGES-')], [sg.Text('Fields: '), sg.Text(size=(30, 1), key='-FIELDS-')], [sg.Text('Encrypted: '), sg.Text(size=(6, 1), key='-ENCRYPTED-')], [sg.Text('Author: '), sg.Text(size=(40, 1), key='-AUTHOR-')], [ sg.Text('Creation Date: '), sg.Text(size=(40, 1), key='-CREATIONDATE-') ], [sg.Text('Creator: '), sg.Text(size=(40, 1), key='-CREATOR-')], [sg.Text('Producer: '), sg.Text(size=(40, 1), key='-PRODUCER-')], [sg.Text('Subject: '), sg.Text(size=(40, 1), key='-SUBJECT-')], [sg.Text('Title: '), sg.Text(size=(40, 1), key='-TITLE-')], [ sg.MLine(key='-ML1-' + sg.WRITE_ONLY_KEY, size=(50, 8), reroute_cprint=True, enable_events=False) ], [ sg.Cancel(), sg.Button(button_text='Reverse', key='-REVERSE-', tooltip=reverseButtonTip) ] ] window = sg.Window('Reverse PDF File', layout, return_keyboard_events=True, resizable=True) return window
def ZhuMain(): fig_dict = { '进度条1': Pb1, '进度条2': Pb2, '进度条3': Pb3, '进度条4': Pb4, '进度条5': Pb5, '进度条6': Pb6, '进度条7': Pb7, '进度条8': Pb8, '进度条9': Pb9, '进度条10': Pb10, '进度条11': Pb11, '进度条12': Pb12, '进度条13': Pb13 } sg.theme('LightGreen') #主题背景设计,默认银河灰 # define the form layout listbox_values = list(fig_dict) col_listbox = [[ sg.Listbox(values=listbox_values, enable_events=True, size=(28, len(listbox_values)), key='-LISTBOX-') ], [sg.Text('★' * 15)], [sg.Exit(size=(5, 2))]] #布局 layout = [ [sg.Text('最全进度条及代码整理', font=('current 10'))], [ sg.Col(col_listbox, pad=(5, (3, 330))), sg.MLine(size=(50, 30), pad=(5, (3, 90)), key='-MULTILINE-') ], #第2行有3个布局 ] # create the form and show it without the plot window = sg.Window('Python3下的最全的进度条整理', layout, grab_anywhere=False, finalize=True) # The GUI Event Loop while True: event, values = window.read() # helps greatly when debugging if event in (None, 'Exit'): # if user closed window or clicked Exit button break choice = values['-LISTBOX-'][ 0] # get first listbox item chosen (returned as a list) func = fig_dict[choice] # get function to call from the dictionary window['-MULTILINE-'].update(inspect.getsource( func)) # show source code to function in multiline window.close()
def fieldSingle(i): return [[ sg.Button("Vai alla pagina", key='-BUTTON' + str(i) + '-', size=(6, 5)), sg.MLine("", key='-FIELD' + str(i) + '-', size=(82, 6), disabled=True, autoscroll=False) ]]
def create_window(): layout = [ [ sg.Canvas(key='controls_cv'), sg.B('Grid on/off'), sg.HSep(), #sg.InputText(key='node_txt'), sg.MLine(change_submits=True, autoscroll=True, visible=True, do_not_clear=True, key="node_txt"), sg.InputText(default_text=0.05, key='round_base', change_submits=True, size=(10, 10), tooltip="set grid spacing"), sg.B('snap to grid'), sg.HSep(), sg.B('LOAD MindMap'), sg.B('SAVE MindMap'), sg.B('Exit'), ], [ sg.Column( layout=[[ sg.Canvas( key='fig_cv', # it's important that you set this size size=(window_width, window_height)) ]], background_color='#DAE0E6', pad=(0, 0)) ], [ sg.B('New MindMap'), sg.T('Matplotlib Style:'), sg.Combo(plt.style.available, default_value=default_style, size=(15, 10), key='-STYLE-'), sg.HSep(), sg.B('Set GUI theme'), sg.T('GUI Theme:'), sg.Combo(sg.theme_list(), default_value=default_theme, size=(15, 10), key='-THEME-') ] ] window = sg.Window('Graph with controls', layout, finalize=True) return window
def init_game_status(self): layout = [ [sg.Column([ [sg.MLine(key='-MLOutput-' + sg.WRITE_ONLY_KEY, size=(60,16))] ], element_justification="center")], [sg.Column([[ self.init_game_button("-MOVE-", "Move"), self.init_game_button("-RESET-", "Reset") ]], justification='center', element_justification="center")] ] return layout
def build_analysis_tab(): fig, save_to, save_as, figure_agg = None, '', '', None func, func_kwargs = None, {} data = {} data_list = [ [sg.Text('DATASETS', **header_kwargs)], [sg.Listbox(values=[], change_submits=False, size=(20, len(data.keys())), key='DATASET_IDS', enable_events=True)], [sg.FolderBrowse(button_text='Add', initial_folder=SingleRunFolder, key='DATASET_DIR', change_submits=True, enable_events=True, **button_kwargs)], [sg.Button('Remove', **button_kwargs), sg.Button('Add ref', **button_kwargs), sg.Button('Change ID', **button_kwargs)], # [sg.Text(' ' * 12)] ] dim = 2000 figure_w, figure_h = dim, dim graph_dict = { 'crawl_pars': plot_crawl_pars, 'angular_pars': plot_ang_pars, 'endpoint_params': plot_endpoint_params, 'stride_Dbend': plot_stride_Dbend, 'stride_Dorient': plot_stride_Dorient, 'interference': plot_interference, 'dispersion': plot_dispersion, 'stridesNpauses': plot_stridesNpauses, 'turn_duration': plot_turn_duration, 'turns': plot_turns, 'odor_concentration': plot_odor_concentration, 'sensed_odor_concentration': plot_sensed_odor_concentration, 'pathlength': plot_pathlength, 'food_amount': plot_food_amount, 'gut': plot_gut, 'barplot': barplot, 'deb': plot_debs, } graph_list = [ [sg.Text('GRAPHS', **header_kwargs)], [sg.Listbox(values=list(graph_dict), change_submits=True, size=(20, len(list(graph_dict))), key='GRAPH_LIST')], [sg.Button('Graph args', **button_kwargs), sg.Button('Draw', **button_kwargs), sg.Button('Save', **button_kwargs)]] graph_code = sg.Col([[sg.MLine(size=(70, 30), key='GRAPH_CODE')]]) graph_canvas = sg.Col([[sg.Canvas(size=(figure_w, figure_h), key='GRAPH_CANVAS')]]) graph_instructions = sg.Col([[sg.Pane([graph_canvas, graph_code], size=(figure_w, figure_h))], [sg.Text('Grab square above and slide upwards to view source code for graph')]]) analysis_layout = [ [sg.Col(data_list)], [sg.Col(graph_list), graph_instructions] ] return analysis_layout, graph_dict, data, func, func_kwargs, fig, save_to, save_as, figure_agg
def print_to_multiline(): layout = [[simpleGUI.Text('Demonstration of Multiline Element Printing')], [simpleGUI.MLine(key='-ML1-' + simpleGUI.WRITE_ONLY_KEY, size=(40, 8))], [simpleGUI.MLine(key='-ML2-' + simpleGUI.WRITE_ONLY_KEY, size=(40, 8))], [simpleGUI.Button('Go'), simpleGUI.Button('Exit')]] window = simpleGUI.Window('Window Title', layout, finalize=True) # Note, need to finalize the window above if want to do these prior to calling window.read() window['-ML1-' + simpleGUI.WRITE_ONLY_KEY].print(1, 2, 3, 4, end='', text_color='red', background_color='yellow') window['-ML1-' + simpleGUI.WRITE_ONLY_KEY].print('\n', end='') window['-ML1-' + simpleGUI.WRITE_ONLY_KEY].print(1, 2, 3, 4, text_color='white', background_color='green') counter = 0 while True: # Event Loop event, values = window.read(timeout=100) if event in (simpleGUI.WIN_CLOSED, 'Exit'): break if event == 'Go': window['-ML1-' + simpleGUI.WRITE_ONLY_KEY].print(event, values, text_color='red') window['-ML2-' + simpleGUI.WRITE_ONLY_KEY].print(counter) counter += 1 window.close()
def the_gui(): """ Starts and executes the GUI Reads data from a global variable and displays Returns when the user exits / closes the window """ sg.theme('Light Brown 3') layout = [[sg.Text('Long task to perform example')], [ sg.MLine(size=(80, 12), k='-ML-', reroute_stdout=True, write_only=True, autoscroll=True, auto_refresh=True)], [sg.Text('Number of seconds your task will take'), sg.Input(key='-SECONDS-', focus=True, size=(5, 1)), sg.Button('Do Long Task', bind_return_key=True), sg.CBox('ONE chunk, cannot break apart', key='-ONE CHUNK-')], [sg.Text('Work progress'), sg.ProgressBar(100, size=(20, 20), orientation='h', key='-PROG-')], [sg.Button('Click Me'), sg.Button('Exit')], ] window = sg.Window('Multithreaded Demonstration Window', layout, finalize=True) timeout = thread = None # --------------------- EVENT LOOP --------------------- while True: event, values = window.read(timeout=timeout) # print(event, values) if event in (sg.WIN_CLOSED, 'Exit'): break elif event.startswith('Do') and not thread: print('Thread Starting! Long work....sending value of {} seconds'.format(float(values['-SECONDS-']))) timeout = 100 if values['-ONE CHUNK-'] else None thread = threading.Thread(target=long_operation_thread, args=(float(values['-SECONDS-']), window), daemon=True) thread.start() if values['-ONE CHUNK-']: sg.popup_animated(sg.DEFAULT_BASE64_LOADING_GIF, background_color='white', transparent_color='white', time_between_frames=100) elif event == 'Click Me': print('Your GUI is alive and well') elif event == '-PROGRESS-': if not values['-ONE CHUNK-']: window['-PROG-'].update_bar(values[event], 100) elif event == '-THREAD-': # Thread has completed thread.join(timeout=0) print('Thread finished') sg.popup_animated(None) # stop animination in case one is running thread, message, progress, timeout = None, '', 0, None # reset variables for next run window['-PROG-'].update_bar(0, 0) # clear the progress bar if values['-ONE CHUNK-'] and thread is not None: sg.popup_animated(sg.DEFAULT_BASE64_LOADING_GIF, background_color='white', transparent_color='white', time_between_frames=100) window.close()
def newUserWindow(): rsaNew = rsa.RSAObj.newUser() sg.theme('Dark Blue 3') layout = [[sg.Text(text="RSA Key: ")], [sg.MLine(str(rsaNew.getN()))], [sg.Text(text="Secondary Key: ")], [sg.MLine(str(rsaNew.getE()))], [sg.Text(text="Private Key: ")], [sg.MLine(str(rsaNew.getD()))], [sg.B("Proceed to Encryption"), sg.B("Proceed to Decryption")]] window = sg.Window('RSA Encryptor', layout) event, values = window.read() nextAction = None if event == "Proceed to Encryption": nextAction = encryptWindow elif event == "Proceed to Decryption": nextAction = decryptWindow else: window.close() if nextAction is not None: layout1 = [[ sg.Text("Would you like to use your newly generated keys?") ], [sg.B("Yes"), sg.B("No")]] window1 = sg.Window('RSA Encryptor', layout1) event, values = window1.read() if event == "Yes": window.close() window1.close() nextAction(rsaNew.getN(), rsaNew.getE(), rsaNew.getD()) elif event == "No": window.close() window1.close() encryptStartingWindow() elif event == sg.WIN_CLOSED or event == 'Exit': window.close() window1.close()
def main(): layout = [[sg.MLine(size=(50, 15), key='Log')], [ sg.Button('Start', bind_return_key=True, key='-START-'), sg.Button('Exit') ]] window = sg.FlexForm('Log window', layout, default_element_size=(30, 2), font=('Helvetica', ' 10'), default_button_element_size=(8, 2), return_keyboard_events=True) window.read(timeout=0) appStarted = False # Setup logging and start app logging.basicConfig(level=logging.DEBUG) log_queue = queue.Queue() queue_handler = QueueHandler(log_queue) logger.addHandler(queue_handler) threadedApp = ThreadedApp() # Loop taking in user input and querying queue while True: # Wake every 100ms and look for work event, values = window.read(timeout=100) if event == '-START-': if appStarted is False: threadedApp.start() logger.debug('App started') window['-START-'].update(disabled=True) appStarted = True elif event in (None, 'Exit'): break # Poll queue try: record = log_queue.get(block=False) except queue.Empty: pass else: msg = queue_handler.format(record) window['Log'].update(msg + '\n', append=True) window.close()
def get_main_menu(): missions_menu = get_missions_menu(MAIN_WIDTH * 2, MAIN_HEIGHT) task_label = sg.Text("Описание миссии:", size=(MAIN_WIDTH, 1), background_color='yellow', text_color='black', pad=(0, 0)) mission_task = deEmojify(planet_01.mission.text) task_text = sg.Text(text=mission_task, key='MISSION_TEXT', size=(MAIN_WIDTH // 2, 10), background_color='white', text_color='black', pad=(0, 0)) task_img = sg.Image(filename=planet_01.mission.ill_path, key='MISSION_IMG') work_zone = sg.Column([[task_label], [task_text], [task_img]], key='WORK_ZONE', visible=True, size=(MAIN_WIDTH * 4, MAIN_HEIGHT), scrollable=True) progr_label = sg.Text("Здесь вы можете писать инструкции диоходу:", size=(MAIN_WIDTH, 1), background_color='white', text_color='black', pad=(0, 0)) snippet = sg.MLine(size=(MAIN_WIDTH // 2, 25), text_color='black', key='USER_CODE', pad=(0, 0)) start_button = sg.Button(button_text="Запустить миссию!", key='START_MISSION', enable_events=True, pad=(0, 10)) progr_zone = sg.Column([[progr_label], [snippet], [start_button]], key='PROGR_ZONE', visible=True, size=(MAIN_WIDTH * 4, MAIN_HEIGHT), scrollable=True) layout = [[missions_menu, work_zone, progr_zone]] window = sg.Window(title="Пульт управления диоходом", layout=layout, margins=(1, 1)) return window
def __init__(self): self.layout = [[sg.Menu(menu_def)], [ sg.T('Search Term', size=(10, 1)), sg.Input(size=(45, 1), focus=True, key='TERM'), sg.Radio('Contains', group_id='choice', key='CONTAINS', default=True), sg.Radio('StartsWith', group_id='choice', key='STARTSWITH'), sg.Radio('EndsWith', group_id='choice', key='ENDSWITH') ], [ sg.T('Root Path', size=(10, 1)), sg.Input('C:/', size=(45, 1), key='PATH'), sg.FolderBrowse('Browse'), sg.Button('Re-Index', size=(10, 1), key='_INDEX_'), sg.Button('Search', size=(10, 1), bind_return_key=True, key='_SEARCH_') ], [ sg.MLine(size=(110, 30), key='_ML_' + sg.WRITE_ONLY_KEY, right_click_menu=right_click_menu, enable_events=True, reroute_stdout=True, autoscroll=True) ], [ sg.Button(button_text='Show In Explorer', key='Explore'), sg.Button('Clear', key='CLEAR'), sg.Button('Exit') ]] self.window = sg.Window('File Search Engine', self.layout)
def init_gui(): sg.theme('Dark Blue 3') layout = [[ sg.Text('Input CSV', size=(10, 1)), sg.Input(key='-INPUT-', change_submits=True), sg.FileBrowse(key='-INPUT_BROWSE-', file_types=(("CSV Files", "*.csv"), )) ], [ sg.Text('PDF Output', size=(10, 1)), sg.Input(key='-PDF_DIR-', change_submits=True), sg.FolderBrowse(key='-INPUT_BROWSE-') ], [ sg.Text('Chromedriver', size=(10, 1)), sg.Input(key='-DRIVER-', change_submits=True), sg.FileBrowse(key='-DRIVER_BROWSE-', file_types=(("EXE Files", "*.exe"), )) ], [ sg.Text('Run in Background', size=(15, 1)), sg.Radio('True', "BGRADIO", default=True, key='-HEADLESS-'), sg.Radio('False', "BGRADIO") ], [sg.MLine(key='-OUTPUT-' + sg.WRITE_ONLY_KEY, size=(70, 20))], [sg.OK(), sg.Cancel()]] # Testing # layout = [ # [sg.Text('Input CSV', size=(10, 1)), sg.Input(default_text='/Users/dlutsch/Desktop/sample2.csv', key='-INPUT-', change_submits=True), # sg.FileBrowse(key='-INPUT_BROWSE-', file_types=(("CSV Files", "*.csv"),))], # [sg.Text('PDF Output', size=(10, 1)), sg.Input(default_text='/Users/dlutsch/Desktop/pdf', key='-PDF_DIR-', change_submits=True), # sg.FolderBrowse(key='-INPUT_BROWSE-')], # [sg.Text('Chromedriver', size=(10, 1)), sg.Input(default_text='/Users/dlutsch/chromedriver',key='-DRIVER-', change_submits=True), # sg.FileBrowse(key='-DRIVER_BROWSE-', file_types=(("EXE Files", "*.exe"),))], # [sg.Text('Run in Background', size=(15, 1)), sg.Radio('True', "BGRADIO", default=True, key='-HEADLESS-'), # sg.Radio('False', "BGRADIO")], # [sg.MLine(key='-OUTPUT-' + sg.WRITE_ONLY_KEY, size=(70, 20))], # [sg.OK(), sg.Cancel()] # ] return sg.Window('Harris County Property Tax Downloader', layout)
def show_result_gui(self): mline = sg.MLine(key="report", font=(font, fs_mid), size=(2*fs_mid, 20)) layout = [ [ sg.Text('Results are in!', justification='center', font=(font, fs_mid), size=(2*fs_mid, 1)) ], [mline], [sg.Text('save: ', font=(font, fs_mid))], [sg.Input(key='name', font=(font, fs_mid), size=(2*fs_mid, 1))], [sg.Button("Save and Exit", font=(font, fs_mid))], ] window = sg.Window('GRE', layout, finalize=True, margins=(4,4)) mline.print(all_text) event, value = window.read() if not value['name']: exit() with open(f"./{value['name']}", "w+") as f: f.writelines(value['report']) window.close()
[sg.InputText('0', size=(3, 1), key='-C-', font='Any 18'),sg.Text('/0', key='-Cnum-', size=(4, 1), font='Any 18'),sg.InputText('0', size=(3, 1), key='-D-', font='Any 18'), sg.Text('/0', key='-Dnum-', size=(4, 1), font='Any 18')], [sg.Text(' ', size=(4, 1), font='Any 18'), ], [sg.Button(u'⬅', size=(4, 1), font='Any 15'), sg.InputText('0', size=(3, 1), key='-INDEX-', font='Any 18'), sg.Text('/0', key='-COUNT-', size=(4, 1), font='Any 18'), sg.Button('➡', size=(4, 1), font='Any 15'), sg.Button('Goto', size=(4, 1), font='Any 15')], [sg.Text('SRC', size=(5, 1), auto_size_text=False, justification='left',font='Any 18'),\ sg.InputText('Default Folder',font='18',size=(17, 1)), \ sg.FolderBrowse()], [sg.Text('TODIR', size=(5, 1), auto_size_text=False, justification='left',font='Any 18'),\ sg.InputText('Default Folder',font='18',size=(17, 1)), \ sg.FolderBrowse()], [sg.Button('START', size=(4, 1), font='Any 15'),sg.Button('DONE', size=(4, 1), font='Any 15')], ] col_multiline = sg.Col([[sg.MLine(size=(70, 35), key='-MULTILINE-')]]) col_canvas = sg.Col([[sg.Canvas(size=(figure_w, figure_h), key='-CANVAS-')]]) col_instructions = sg.Col([ [sg.Pane([col_canvas, col_multiline], size=(700, 500))], [ sg.Text( 'Grab square above and slide upwards to view source code for graph' ) ] ]) layout = [ [sg.Text('AFM Sigle Molecular Force Spectrum', font=('ANY 18'))], [sg.Col(col_listbox, justification='t'), col_instructions], ] window = sg.Window('DataYEE6', layout, resizable=True, finalize=True)
'Pyplot Box Plot' : PyplotBoxPlot, 'Pyplot ggplot Style Sheet' : PyplotGGPlotSytleSheet, 'Pyplot Line Poly Collection' : PyplotLinePolyCollection, 'Pyplot Line Styles' : PyplotLineStyles, 'Pyplot Scatter With Legend' :PyplotScatterWithLegend, 'Artist Customized Box Plots' : PyplotArtistBoxPlots, 'Artist Customized Box Plots 2' : ArtistBoxplot2, 'Pyplot Histogram' : PyplotHistogram} sg.theme('LightGreen') figure_w, figure_h = 650, 650 # define the form layout listbox_values = list(fig_dict) col_listbox = [[sg.Listbox(values=listbox_values, enable_events=True, size=(28, len(listbox_values)), key='-LISTBOX-')], [sg.Text(' ' * 12), sg.Exit(size=(5, 2))]] layout = [[sg.Text('Matplotlib Plot Test', font=('current 18'))], [sg.Col(col_listbox, pad=(5, (3, 330))), sg.Canvas(size=(figure_w, figure_h), key='-CANVAS-') , sg.MLine(size=(70, 35), pad=(5, (3, 90)), key='-MULTILINE-')],] # create the form and show it without the plot window = sg.Window('Demo Application - Embedding Matplotlib In PySimpleGUI', layout, grab_anywhere=False, finalize=True) figure_agg = None # The GUI Event Loop while True: event, values = window.read() # print(event, values) # helps greatly when debugging if event in (sg.WIN_CLOSED, 'Exit'): # if user closed window or clicked Exit button break if figure_agg: # ** IMPORTANT ** Clean up previous drawing before drawing again delete_figure_agg(figure_agg) choice = values['-LISTBOX-'][0] # get first listbox item chosen (returned as a list) func = fig_dict[choice] # get function to call from the dictionary
[sg.T('"Adobe Connect Meetings Tools"', pad=(220, 0))], [sg.T('University:')], [ sg.Combo([ 'Khaje Nasir Toosi University Of Technology', 'University Of Tehran', 'Isfahan University Of Technology', 'Imam Khomeini International University' ], key='-UNI-') ], [sg.T('Username:'******'-USERNAME-', size=(25, 1))], [sg.T('Password:'******'-PASSWD-', size=(25, 1))], [sg.T('Mettings Links:')], [sg.MLine(key='-LINKS-', size=(150, 8))], [sg.Button('Download'), sg.Button('Export-Only')], ] window = sg.Window('Adobe Connect Meetings Tools', layout, size=(800, 450), grab_anywhere=True, resizable=True) while True: event, values = window.read() if event == sg.WIN_CLOSED: break
def get_layout(): frame_campaign = [ inner_element_space(600), [ sg.Text("Selecione o Código"), sg.In(key="-Code-", size=(30, 1)), sg.FileBrowse( "Selecionar", file_types=(("Códigos Python", "*.py"), ), size=(15, 1), ) ], [ sg.Text("Selecione a Lista de Destinatários"), sg.Combo( lista, lista[1], key="-Lists-", ) ], inner_element_space(600), ] frame_email = [ inner_element_space(600), [ sg.Text( "Insira o título", font=("Helvetica 15"), ), sg.In( key="-Title-", size=(62, 1), ) ], [ sg.Text( "Insira o Conteúdo", font=("Helvetica 15"), ), sg.MLine( key="-Content-", size=(60, 10), ) ], inner_element_space(600), ] layout = [ [ sg.Frame( "Configurações de Campanha", frame_campaign, element_justification="c", ) ], [ sg.Frame( "Configurações do E-mail", frame_email, element_justification="c", ) ], [ sg.Button( "Enviar E-mail", key="-Send-", size=(15, 1), pad=(10, (10, 0)), ), sg.Button( "Gerenciar Listas", key="-ListEditor-", size=(15, 1), pad=(10, (10, 0)), ) ], inner_element_space(600), ] return layout
def 控件(): menu_def = [['&File', ['&Open', '&Save', 'E&xit', 'Properties']], ['&Edit', ['Paste', ['Special', 'Normal', ], 'Undo'], ],['&Help', '&About...'], ] # ------ Column Definition ------ # #当较小的元素左侧有一个较高的元素时,则需要一列。 #将来也放到layout的一个控件里面sg.Column(col, background_color='blue') column1 = [[sg.Text('Column 1', justification='center', size=(10, 1))], [sg.Spin(values=('Spin Box 1', '2', '3'),initial_value='Spin Box 1')], [sg.Spin(values=('Spin Box 1', '2', '3'),initial_value='Spin Box 2')], [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]] layout = [ [sg.Menu(menu_def, tearoff=True)], #文本显示内容,那个relief参数可以添加阴影效果 #sg.RELIEF_RIDGE,RELIEF_RAISED为外凸效果 #sg.RELIEF_FLAT平滑效果,也就是默认值 #RELIEF_GROOVE,sg.RELIEF_SUNKEN内凹效果 #RELIEF_SOLID黑框选中 [sg.Text('(Almost) All widgets in one Window!', size=( 30, 1), justification='center', font=("Helvetica", 25),relief=sg.RELIEF_RIDGE)], [sg.Text('Here is some text.... and a place to enter text')], # 单行文本输入框 [sg.InputText('This is my text')], #框架组件,之前说过 [sg.Frame(layout=[ #复选框,将来valuse的返回值只有False,True [sg.CBox('这里输什么将来就显示什么', size=(10, 1)), sg.CBox('My second checkbox!', default=True)], #这里是单选框,第一个参数是实际显示值,第二个是id,这个只要学过HTML的都懂吧 [sg.Radio('My first Radio! ', "123",default=True, size=(10, 1)), sg.Radio('My second Radio!', "123")]], title='Options', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags')], #这个是多行输入框 [sg.MLine(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), sg.MLine(default_text='A second multi-line', size=(35, 3))], #这个是多选一框(好像叫selectbox),就是那种选择出身年份的,name和value都很好懂 [sg.Combo(('Combobox 1', 'Combobox 2'), default_value='Combobox 1', size=(20, 1)), #用来滑动的条,你可以选择滑动条的范围,方向"h"/"v",尺寸,默认值 #实际值就是你拖动的结果 sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], #不知道是个啥,跟上面那个Combo很像 [sg.OptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))], #就是你平时用browse实际出来的那个有拖动条的那种 #功能上跟Combo很像 [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3))], #可以画线,还可以展位(用" ") [sg.Text('_' * 100)], #File选择器,值就是你选中的File的路径 [ sg.FolderBrowse()], #快捷方式按钮,还有提示tooltip就是你把光标移动到控件旁边后会提示的小白色的提示框 [sg.Submit(tooltip='Click to submit this form'), sg.Cancel()]] window = sg.Window('Everything bagel', layout, no_titlebar=True, default_element_size=(40, 1), grab_anywhere=False, ) event, values = window.read()
def main(): ''' Main Function ''' table_data = [] logging.basicConfig(level=config.LOGGING_LEVEL, format=config.LOGGING_FORMAT) twbuttonlogic = TwButtonLogic() input_tfields = ["date", "starttime", "stoptime", "taskdesc"] timew_summary_columns = ['Tag', 'Duration'] # # Load inital tracked time data twbuttonlogic.collect_tasks_list() table_data, tag_len = twbuttonlogic.return_task_table() logging.debug("tag_len: %s", tag_len) # if empty table set correct column and rows table_data.append([" " * 27, ""]) active_timer = twbuttonlogic.get_active_timer() # # Define the window's contents sg.theme(config.THEME) layout = [ [ sg.Text("Task:", size=(5, 1), font=config.GLOBAL_FONT), \ sg.Input(key="taskdesc", size=(35,1), font=config.GLOBAL_FONT) ], \ [ sg.Frame(layout=[ [ sg.Text("Start Time:", size=(8, 1), font=config.GLOBAL_FONT), \ sg.Input(key="starttime", size=(12,1), font=config.GLOBAL_FONT), \ sg.Text("EX: 15:00", font=config.GLOBAL_FONT) ], [ sg.Text("Stop time:", size=(8, 1), font=config.GLOBAL_FONT), \ sg.Input(key="stoptime", size=(12,1), font=config.GLOBAL_FONT), \ sg.Text("EX: 15:00", font=config.GLOBAL_FONT) ], [ sg.Text("Date:", size=(8, 1), font=config.GLOBAL_FONT), \ sg.Input(key="date", size=(12,1), font=config.GLOBAL_FONT), \ sg.Text("EX: 2020-10-01", size=(16,1), font=config.GLOBAL_FONT) ] ], title='Date') ], # Buttons [ sg.Button('Start', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), \ sg.Button('Stop', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), \ sg.Button('Modify', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), \ sg.Button('Track', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), ], [ sg.Button('Continue', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), \ sg.Button('Delete', size=(config.BUTTON_SIZE, 1),font=config.GLOBAL_FONT), \ sg.Button('Details', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), \ sg.Button('Rename', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT) ], \ [ sg.Button('Refresh', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), ], # Calendar Buttons inserted here if enabled # Text Boxes [ sg.Text("Current Tracking:", size=(13,1), font=config.GLOBAL_FONT), sg.Input(key="curr_tracking", size=(27,1), default_text=active_timer, \ font=config.GLOBAL_FONT) ], [ sg.MLine(key="cliout", size=(40,8), font=config.GLOBAL_FONT) ], [ sg.Text(size=(40,1), key='status_result', font=config.GLOBAL_FONT) ], [ sg.Text("Todays Tasks", font=config.GLOBAL_FONT) ], [ sg.Table(values=table_data, headings=timew_summary_columns, max_col_width=30, display_row_numbers=False, justification='left', num_rows=20, key='timew_table', tooltip='Todays Data', font=config.GLOBAL_FONT)] ] if config.ICALBUDDY_ENABLE: calendar_buttons = [ sg.Button('Start Meeting', font=config.GLOBAL_FONT), \ sg.Button('Fix Start', size=(config.BUTTON_SIZE, 1), font=config.GLOBAL_FONT), \ sg.Button('Calendar Track', font=config.GLOBAL_FONT)] layout.insert(4, calendar_buttons) window = sg.Window('Timewarrior Tracking', layout) # ####### Event Loop while True: logging.debug("****** Start Main Loop ******") logging.debug("table_data: %s", table_data) # # Read Button triggers event, values = window.read() # Clean up and Close if event in (sg.WINDOW_CLOSED, 'Quit'): break # # Input Validation if values['date'] != '': if validate_date(values['date']): sg.popup('Invalid date please use format "YYYY-MM-DD" data entered:', \ values['date']) continue if values['starttime'] != '': if validate_time(values['starttime']): sg.popup('Invalid date please use format "HH:MM" data entered:', \ values['starttime']) continue if values['stoptime'] != '': if validate_time(values['stoptime']): sg.popup('Invalid date please use format "HH:MM" data entered:', \ values['stoptime']) continue if values['stoptime'] != '' and values[ 'starttime'] != '' and event == 'Modify': sg.popup( 'Can only change start or end time, clear one of the fields') continue if (event in ('Track', 'Start')) and values['taskdesc'] == '': sg.popup('Task Name Can not be Empty') continue # # Button Logic result, result_display = twbuttonlogic.button_logic(event, values) logging.debug("button_logic result: %s", result) # # Update list of tracked time for today table_data, tag_len = twbuttonlogic.return_task_table() window['timew_table'].update(values=table_data) active_timer = twbuttonlogic.get_active_timer() window['curr_tracking'].update(active_timer) # # Return results and Status window['status_result'].update(result_display) window['cliout'].update(str(result, config.ENCODING)) # # clear input fields for i in input_tfields: window[i].update('') window.close() return 0
], [ sg.Listbox( values=[ '', '', '', '', '', '', '', '', '', '', '', '', '', 'Results will appear here' ], enable_events=True, size=(80, 30), key="results" # results ), ], ] right_column = [ [sg.MLine(key='extra_info', size=(70, 30), autoscroll=False)] # [sg.Text(size=(60, 30), key="extra_info", text="\n \n \n \n \n \n \n \n \n \n \n \n \n \n")] ] img_column = [[image_elem], [sg.Button('Play'), sg.Button('Pause')], [sg.Button('Open on Spotify')]] layout = [[ sg.Column(left_column), sg.VSeperator(), sg.Column(right_column), sg.VSeperator(), sg.Column(img_column, element_justification='center') ]]
], [ sg.Text('File to open: '), sg.Input(key='-FILE-', enable_events=True), sg.FileBrowse(file_types=(("Text Files", "*.txt"), )) ], [ sg.Multiline('', key='-IN-', size=(100, 10), enable_events=True) ], [ sg.MLine(size=(100, 10), key='-OUTPUT-', disabled=True) ], [ sg.Text('Order: '), sg.Drop(values=('2', '3', '4', '5', '6'), auto_size_text=True, key='-D1-') ], [ sg.Text('Max iterations: '), sg.Input(key='-IN2-', size=(10, 10)) ], [ sg.Checkbox('Dynamic generation', default=False,
sg.CBox('My second checkbox!', default=True) ], [ sg.Radio('My first Radio! ', "RADIO1", default=True, size=(10, 1)), sg.Radio('My second Radio!', "RADIO1") ]], title='Options', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags') ], [ sg.MLine( default_text= 'This is the default Text should you decide not to type anything', size=(35, 3)), sg.MLine(default_text='A second multi-line', size=(35, 3)) ], [ sg.Combo(('Combobox 1', 'Combobox 2'), default_value='Combobox 1', size=(20, 1)), sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85) ], [sg.OptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))], [ sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)),
def block_app(protein): import json import os import textwrap import pprint import PySimpleGUI as sg from .seq_tools import makeblock from .seq_tools import clean_block from .seq_tools import freq_check from .info_app import analyze_block_info ROOT = os.environ.get('ROOT') user_dir = os.path.join(ROOT, 'data', 'user_data') work_protein = os.path.join(ROOT, 'data', 'user_data', 'builds', protein) with open(work_protein, 'r') as file: work_protein = json.loads(file.read()) # print(work_protein) sg.theme('DarkPurple6') motslist = [i['mot'] for i in work_protein['mots']] layout = [[sg.Frame(layout=[[sg.Text('Mot for analyze', font=('Helvetica', 14)), sg.Combo(motslist, key="-MOT-", size=(20, 5), default_value=motslist[0]), sg.Text(size=(15, 1), key="-MOTOUT-")], [sg.Text('Block size', font=('Helvetica', 14)), sg.Slider(range=(10, 70), key="-SIZE-", default_value=30, size=(20, 15), orientation='horizontal', font=('Courier New', 14))]], title='Block options', title_color='red', font=('Courier New', 15))], [sg.Button('Make block'), sg.Button('Info'), sg.Button('Back')], ] window = sg.Window('Choose mot for Block', layout) # ------------ window Event Loop-------------- while True: event, values = window.read() # print(event, values) if event == sg.WIN_CLOSED: return 'Close' elif event == 'Back': break elif event == 'Info': window.Hide() analyze_block_info() window.UnHide() elif event == 'Make block': window["-MOTOUT-"].Update(values["-MOT-"]) for i in work_protein['mots']: if i['mot'] == values["-MOT-"]: info = i res = makeblock(info=info, size=int(values["-SIZE-"])) headers = ['block', 'name', 'organism', 'dT'] weights = res['block_weights'] out = [] for i in range(len(weights)): line = '' for item in sorted(weights[i].items(), key=lambda pair: pair[1], reverse=True): line = line + f' {item[0]} - {item[1]} ' out.append([i + 1, line]) data = [[i['block'], i['name'], i['organism'], i['dT']] for i in res['finds']] window.Hide() tab1_layout = [ [sg.Text(f'Анализируемый мот {values["-MOT-"]}')], [sg.Table(values=data, justification="left", headings=headers, font=('Courier New', 14), num_rows=20, max_col_width=30, key='-OUT1-')], [sg.Input(key='lettimes', size=(5, 1)), sg.Text('Letter Frequency'), sg.Frame(layout=[[sg.Input(key='pos', size=(5, 1)), sg.Text('Position'), sg.Input(key='lett', size=(5, 1)), sg.Text('Letter')]], title='Select by letter'), sg.Checkbox('Splitted', key='split'), sg.Button('Filter'), sg.Button('Clean')] ] tab2_layout = [[sg.Table(values=out, headings=['Position', 'Letters'], justification="left", font=('Courier New', 12), num_rows=20, max_col_width=100, key='-OUT2-')]] layout2 = [[sg.TabGroup([[sg.Tab('Block', tab1_layout), sg.Tab('Positions', tab2_layout)]])], [sg.Button('Save Block'), sg.Button('Copy selected'), sg.Button('Info'), sg.Button('Back')]] window2 = sg.Window('Анализ блока', layout2) # ----------------------window2 Event Loop----------------------------- while True: event2, values2 = window2.read() # print(event2, values2) if event2 == sg.WIN_CLOSED: return 'Close' elif event2 == 'Back': window2.close() window.UnHide() break elif event2 == 'Info': window2.Hide() analyze_block_info() window2.UnHide() elif event2 == 'Filter': if values2['lettimes'] != '': res = clean_block(res, lettimes=int(values2['lettimes'])) data = [[i['cblock'], i['name'], i['organism'], i['dT']] for i in res['finds']] else: pass if values2['pos'] != '' and values2['lett'] != '': data = freq_check(data, int(values2['pos']), values2['lett'].upper()) window2['-OUT1-'].Update(data) if values2['split'] == True: for protein in data: line = '' for seq in textwrap.wrap(protein[0], 10): line = line + seq + ' ' protein[0] = line window2['-OUT1-'].Update(data) if event2 == 'Clean': data = [[i['block'], i['name'], i['organism'], i['dT']] for i in res['finds']] window2['-OUT1-'].Update(data) if event2 == 'Save Block': d_filename = f'{res["mot"]}-block' layout_save = [[sg.Text('Choose destination folder and file name or use default')], [sg.Input(key='-FILEPATH-', default_text=user_dir), sg.FolderBrowse()], [sg.Input(key='-FILENAME-', default_text=d_filename)], [sg.Button("Save")]] event_s, values_s = sg.Window('Save destination', layout_save).read(close=True) if values_s['-FILENAME-'] != d_filename and values_s['-FILENAME-'] != '': d_filename = values_s['-FILENAME-'] if values_s['-FILEPATH-'] == user_dir: filename = f'{user_dir}/{d_filename}.csv' else: filename = f'{values_s["-FILEPATH-"]}/{d_filename}.csv' with open(filename, 'w') as file: line = ' Block; Protein name; Organism; dT\n' file.write(line) for i in data: line = f' {i[0]}; {i[1]}; {i[2]}; {i[3]}\n' file.write(line) if event2 == 'Copy selected': if len(values2['-OUT1-']) > 0: text = '' for i in values2['-OUT1-']: for find in res['finds']: if data[i][1] == find['name'] and data[i][2] == find['organism'] and data[i][0] == find['block']: text = text + f'Organism - {find["organism"]}\nProtein Name-{find["name"]}\nSequence - {find["seq"]}\nBlock - {find["block"]}\n\n' layout_copy = [[sg.MLine(text, size=(80,12))], [sg.Button("Close")]] window_copy = sg.Window("Copied proteins", layout_copy) while True: event_copy, values_copy = window_copy.read() # print(event2, values2) if event_copy in (sg.WIN_CLOSED,"Close"): break window_copy.close() else: print('Copy error') window.close()
sg.Table([["parionssport", "0000", "0000", "0000"]], headings=["Cotes", "1", "N", "2"], key="ODDS_UNDER_CONDITION", visible=False, hide_vertical_scroll=True, size=(None, 12)), sg.Column([[ sg.Text( "Répartition des mises (les totaux affichés prennent en " "compte les éventuels freebets) :", key="TEXT_UNDER_CONDITION", visible=False) ], [ sg.MLine(size=(100, 12), key="RESULT_UNDER_CONDITION", font="Consolas 10", visible=False) ]]) ], [ sg.Column(column_indicators_under_condition), sg.Column(column_results_under_condition) ] ] column_text_stake = [[sg.Text("Mise")], [sg.Text("Cote minimale")]] column_fields_stake = [[sg.InputText(key='BET_STAKE', size=(6, 1))], [sg.InputText(key='ODD_STAKE', size=(6, 1))]] column_stake = [[sg.Column(column_text_stake), sg.Column(column_fields_stake)], [
import kntu_vc_dl import threading sg.theme("Reddit") def download_thread(values, window): pasted_urls = values['-LINKS-'].split("\n") kntu_vc_dl.kntu_download(values['-USERNAME-'], values['-PASSWD-'], pasted_urls) window.reappear() layout = [[sg.T("Username:"******"-USERNAME-", size=(20, 1))], [sg.T("Password:"******"-PASSWD-", size=(20, 1))], [sg.T("Links:")], [sg.MLine(key="-LINKS-", size=(60, 15))], [sg.Button("START")]] window = sg.Window('Adobe Connect Based Meeting Downloader', layout, size=(500, 500)) while True: event, values = window.read() if event == sg.WIN_CLOSED: break elif event == "START": window.disappear() threading.Thread(target=download_thread, args=(values, window)).start()