]) # Draw fit options frame result_box = sg.Multiline( 'A = None +/- None\nB = None +/- None\nC = None +/- None', key='results1', disabled=1, size=(40, 3)) s3 = (3, 1) s4 = (23, 1) s5 = (16, 1) option_frame = sg.Frame( title='Fit options', size=(figure_w, figure_h), layout=[[sg.Text('Select fit function: ', (26, 1))], [sg.Listbox(function_labels, key='fit_func', size=(38, 3))], [sg.Text('Initial parameter values:')], [ sg.Text('A:', s3), sg.Input(size=s4, key='p1', enable_events=1), sg.Checkbox('Keep fixed', key='p1_const') ], [ sg.Text('B:', s3), sg.Input(size=s4, key='p2', enable_events=1), sg.Checkbox('Keep fixed', key='p2_const') ], [ sg.Text('C:', s3), sg.Input(size=s4, key='p3', enable_events=1), sg.Checkbox('Keep fixed', key='p3_const')
def layoutVisuGraph(list_panel, layout_graph_drawing, layout_color_drawing): col_graphs1 = [ [ sg.Text('Input : List of genes', text_color='#e4e4e4', background_color='#343434') ], [ sg.Listbox( values=genes_names_list, select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20, 15), tooltip= 'Highlighted genes will be set to 1 at the start of each simulation run if the choice of genes initial states parameter is << specified >>' ) ], ] col_graphs2 = [ [ sg.Frame(layout=[ [ sg.Text('State', text_color='#e4e4e4', background_color='#343434', tooltip='Select number state'), sg.Combo(values=list_panel, default_value=list_panel[0]), sg.Text('Layout', text_color='#e4e4e4', background_color='#343434'), sg.Combo(values=layout_graph_drawing, default_value=layout_graph_drawing[0]) ], [ sg.Text('Active genes color', text_color='#e4e4e4', background_color='#343434', tooltip='Select color of inactive genes'), sg.Combo(values=layout_color_drawing, default_value=layout_color_drawing[3]), sg.Text('Inactive genes color', text_color='#e4e4e4', background_color='#343434', tooltip='Select color of inactive genes'), sg.Combo(values=layout_color_drawing, default_value=layout_color_drawing[0]) ], [ sg.Text('Active interaction color', text_color='#e4e4e4', background_color='#343434', tooltip='Select color of active interaction'), sg.Combo(values=layout_color_drawing, default_value=layout_color_drawing[10]), sg.Text('Inactive interaction color', text_color='#e4e4e4', background_color='#343434', tooltip='Select color of inactive interaction'), sg.Combo(values=layout_color_drawing, default_value=layout_color_drawing[10]) ], [ sg.Text('Width active Interaction', text_color='#e4e4e4', background_color='#343434', tooltip='Value must a number'), sg.InputText(size=(5, 1), default_text="1") ], [sg.Button('Launch visualization')] ], title='Vsualization settings', title_color='#e4e4e4', background_color='#343434', relief=sg.RELIEF_GROOVE) ], [ sg.Frame( layout=[[sg.Button('Save graph'), sg.InputText(size=(35, 1))]], title='Save Data', title_color='#e4e4e4', background_color='#343434', relief=sg.RELIEF_GROOVE, tooltip='The file extension CSV will be automatically added') ], [ sg.Frame( layout=[[sg.Button('Save gene activity')]], title='Save gene activity graph', title_color='#e4e4e4', background_color='#343434', relief=sg.RELIEF_GROOVE, tooltip='The file extension CSV will be automatically added') ], [sg.Text('', background_color='#343434')] ] layout_graphs = [[ sg.Column(col_graphs1, background_color='#343434'), sg.Column(col_graphs2, background_color='#343434') ], [ sg.Text('Extract core network :', text_color='#e4e4e4', background_color='#343434') ], [sg.Exit()]] window_graphs = sg.Window("Initialize Network", alpha_channel=0.95, layout=layout_graphs) return window_graphs
listaLocalidades = pd.read_csv( "https://raw.githubusercontent.com/Jondiii/appContenedores/master/localidades.txt", delimiter=sep, header=header) #Mirar si se puede buscador y lista plan = [ [sg.Text('Número de días', size=(15, 1)), sg.InputText()], [sg.Text('Localidad')], [sg.Input(size=(20, 1), enable_events=True, key='-INPUT-')], #Lista [ sg.Listbox(values=listaLocalidades, size=(100, 8), enable_events=True, key='-LIST-') ] ] #No es necesario, es un intento para ver si detecta el valor #[sg.Listbox(values=listaLocalidades, size=(100, 8), key='-LIST-', enable_events=True,bind_return_key=True)]] #Otra opción qe igual es mejor #[sg.Combo(listaLocalidades, size=(15, 1), key='_LIST_')]] camiones = [[sg.Text('Número de camiones', size=(20, 1)), sg.InputText()], [sg.Text('Capacidad de camiones', size=(20, 1)), sg.InputText()], [sg.Text('Velocidad de camiones', size=(20, 1)), sg.InputText()]]
def main_win(dbase, u_id, user_name): song_list = [] cash = {} # 歌名与id缓存 f_b1 = sg.Radio('按歌手全称搜索', None, default=True) f_b2 = sg.Radio('按歌手简称搜索', None) f_b3 = sg.Radio('按歌名全称搜索', None) f_b4 = sg.Radio('按歌名简称搜索', None) find_func = { f_b1: lambda d, v: _find_data(d, v, 'singer'), f_b2: lambda d, v: _find_data(d, v, 'singer_py'), f_b3: lambda d, v: _find_data(d, v, 'song'), f_b4: lambda d, v: _find_data(d, v, 'song_py'), } rank = sg.Listbox(values=[], disabled=True, size=(40, 22), auto_size_text=True) find = sg.Listbox(values=[], select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED, size=(40, 19)) song = sg.Listbox(values=[], size=(40, 20), select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED) c_v, n_cash = _get_collection(dbase, u_id) cash.update(n_cash) collection = sg.Listbox(values=c_v, size=(40, 20), select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED) pyin = sg.Input() # 框架1 layout1 = [ [sg.Text('今日排行:')], [rank], ] frame1 = sg.Frame(title=None, layout=layout1) # 框架2 layout2 = [[sg.Text('请输入歌手/歌名(均可简写):')], [pyin], [f_b1, f_b2], [f_b3, f_b4], [find], [sg.Button('查找'), sg.Button('点歌'), sg.Button('收藏')]] frame2 = sg.Frame(title=None, layout=layout2) # 框架3 layout3 = [[sg.Text('已选歌曲:')], [song], [sg.Button('置顶'), sg.Button('删除')]] frame3 = sg.Frame(title=None, layout=layout3) # 框架4 layout4 = [[sg.Text('已收藏:')], [collection], [sg.Button('加入歌单'), sg.Button('取消收藏')]] frame4 = sg.Frame(title=None, layout=layout4) # 整合 layout = [ [frame1, frame4, frame2, frame3], ] window = sg.Window(f'欢迎用户:{user_name}来到ktv点歌系统!!', layout) while True: event, values = window.read() # print(values) if event is None: break if event == '查找': for key in find_func.keys(): if key.get(): song_data, new_values = find_func[key](dbase, values[2]) cash.update(song_data) find.update(values=new_values) if event == '点歌': length = len(song_list) for num, vl in enumerate(values[7]): sname = vl.split(".")[1] song_list.append(f'{length + num + 1}.{sname}') dbase.update_rank(sname.split('-')[0]) if event == '置顶': for x in values[-1]: song_list.remove(x) song_list = [*values[-1], *song_list] song_list = [ f'{num + 1}.{vl.split(".")[1]}' for num, vl in enumerate(song_list) ] if event == '删除': for i in values[-1]: song_list.remove(i) song_list = [ f'{num + 1}.{vl.split(".")[1]}' for num, vl in enumerate(song_list) ] if event == '收藏': for i in values[-2]: v = i.split('-')[0].split('.')[1] if not dbase.add_collections(u_id, cash.get(v)): sg.popup('连接网络出错!', title='提示') break if event == '加入歌单': length = len(song_list) for num, vl in enumerate(values[1]): sname = vl.split(".")[1] song_list.append(f'{length + num + 1}.{sname}') dbase.update_rank(sname.split('-')[0]) if event == '取消收藏': for i in values[1]: if not dbase.delete_collection( u_id, cash[i.split('-')[0].split('.')[1]]): sg.popup('连接网络出错!', '提示') break collection_v, up_cash = _get_collection(dbase, u_id) cash.update(up_cash) rank_v = _get_rank_data(dbase) collection.update(values=collection_v) rank.update(disabled=False, values=rank_v) rank.update(disabled=True) song.update(values=song_list) window.refresh() print(cash) window.close()
# Yair Gat 18.2.2021 # This file represents the client side. import socket import PySimpleGUI as sg import json from City import City capitals = City() capital_arr = capitals.get_cities() # Array of all cities. information_type = ['Weather', 'Time', 'Local News'] # All optional information. sg.theme('DarkGrey9') layout = [[sg.Text('Chose city and information type you want to know:')], [sg.Listbox(values=capital_arr, size=(30, 6), key='City')], [sg.Combo(information_type, key='InfoType')], [sg.Button(button_text='Show Information', enable_events=True)], [sg.Button('Exit')]] window = sg.Window( 'Information about Cities ', layout) # Open gui window with title 'information about cities' HOST = '127.0.0.1' # The server's hostname or IP address PORT = 65432 # The port used by the server while True: # Event Loop event, values = window.read() flag = 0 # The flag changes to 1 when the client is clicking on Exit. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) if event in (sg.WIN_CLOSED, 'Exit'): s.send('close'.encode()) flag = 1 else:
import sys import PySimpleGUI as sg from PySimpleGUIHelper import PySimpleGUIHelper as sg_helper print("hi!!") # https://teratail.com/questions/49758 # https://sites.google.com/site/pythoncasestudy/home/tkinterdedrag-drop-ctypes-shi-yong sg.theme("Dark Blue 3") layout = [[sg.Text("Test GUI.")], [sg.Text("ListBox:")], [ sg.Listbox(key="list_box", values=["test1", "test2"], size=(50, 10), enable_events=True) ], [sg.Text("TextBox:")], [sg.InputText(key="input_text", default_text="hoge")]] window = sg.Window("test window.", layout, finalize=True) #window.Finalize() def dad_list_box(dn: str): print("[list_box] D&D accepted! Get: " + dn) def dad_text_box(dn: str): print("[input_text] D&D accepted! Get: " + dn)
def end_drag(self, desktop, img_size): if self.drag_start == self.drag_end: return classColors = self.classColors option_classes = self.option_classes class_event, class_values = sg.Window('Choose an class', [[sg.Text('Class name ->'), sg.Listbox(option_classes, size=(20, 6), \ key='class_choose')], [sg.Button('Ok'), sg.Button('Cancel')]]).read(close=True) #刪除rectangle if self.prior_rect: desktop.delete_figure(self.prior_rect) #popup menu for class: https://stackoverflow.com/questions/62559454/how-do-i-make-a-pop-up-window-with-choices-in-python if class_event == 'Ok': img_bboxes = self.img_bboxes img_rects = self.img_rects selection = class_values["class_choose"][0].split('_') color_c = classColors[int(selection[0])] if(self.drag_end[1]>self.drag_start[1]): #由下方往上拉矩形, 故值需交換 tmp = self.drag_start self.drag_start = self.drag_end self.drag_end= tmp print(self.drag_start, self.drag_end) class_rect = desktop.draw_rectangle(self.drag_start, self.drag_end, line_color=self.rgb2hex(color_c)) desktop.DrawText(selection[2], self.drag_start, font=("Courier New", 12), color=self.rgb2hex(color_c), \ text_location=sg.TEXT_LOCATION_TOP_LEFT) #sg.popup(f'You chose {class_values["class_choose"][0]}') img_bboxes.append([self.drag_start[0], img_size[1]-self.drag_start[1], \ abs(self.drag_end[0]-self.drag_start[0]), abs(self.drag_end[1]-self.drag_start[1])]) img_rects.append(self.prior_rect) print('img size', img_size) print('img_bboxes', img_bboxes) print('img_rects', img_rects) self.img_bboxes = img_bboxes self.img_rects = img_rects self.drag_start, self.drag_end = None, None # enable grabbing a new rect self.dragging = False
background_color='white', text_color='black', key='notes') ], [ sg.Text('Output:', pad=((3, 0), 0)), sg.Text('', size=(44, 1), text_color='white', key='output') ], [ sg.CBox('Checkbox:', default=True, pad=((3, 0), 0), disabled=True, key='cbox'), sg.Listbox((1, 2, 3, 4), size=(8, 3), disabled=True, key='listbox'), sg.Radio('Radio 1', default=True, group_id='1', disabled=True, key='radio1'), sg.Radio('Radio 2', default=False, group_id='1', disabled=True, key='radio2') ], [ sg.Spin((1, 2, 3, 4), 1, disabled=True, key='spin'), sg.OptionMenu((1, 2, 3, 4), disabled=True, key='option'),
sg.ChangeLookAndFeel('Dark') sg.SetOptions(element_padding=(0, 0)) layout = [[ sg.T('Notes:', pad=((3, 0), 0)), sg.In(size=(44, 1), background_color='white', text_color='black', key='notes') ], [ sg.T('Output:', pad=((3, 0), 0)), sg.T('', size=(44, 1), text_color='white', key='output') ], [ sg.CBox('Checkbox:', default=True, pad=((3, 0), 0), key='cbox'), sg.Listbox((1, 2, 3, 4), size=(8, 3), key='listbox'), sg.Radio('Radio 1', default=True, group_id='1', key='radio1'), sg.Radio('Radio 2', default=False, group_id='1', key='radio2') ], [ sg.Spin((1, 2, 3, 4), 1, key='spin'), sg.OptionMenu((1, 2, 3, 4), key='option'), sg.Combo(values=(1, 2, 3, 4), key='combo') ], [sg.Multiline('Multiline', size=(20, 3), key='multi')], [sg.Slider((1, 10), size=(20, 20), orientation='h', key='slider')], [ sg.ReadFormButton('Enable', button_color=('white', 'black')), sg.ReadFormButton('Disable', button_color=('white', 'black')), sg.ReadFormButton('Reset', button_color=('white', '#9B0023'), key='reset'),
def main(): # ---------------- Create Form ---------------- # sg.change_look_and_feel('Topanga') layout = [ [ sg.Text('Process Killer - Choose one or more processes', size=(45, 1), font=('Helvetica', 15), text_color='red') ], [ sg.Listbox(values=[' '], size=(50, 30), select_mode=sg.SELECT_MODE_EXTENDED, font=('Courier', 12), key='-processes-') ], [ sg.Text( 'Click refresh once or twice.. once for list, second to get CPU usage' ) ], [ sg.Text('Filter by typing name', font='ANY 14'), sg.Input(size=(15, 1), font='any 14', key='-filter-') ], [ sg.Button('Sort by Name', ), sg.Button('Sort by % CPU', button_color=('white', 'DarkOrange2')), sg.Button('Kill', button_color=('white', 'red'), bind_return_key=True), sg.Exit(button_color=('white', 'sea green')) ] ] window = sg.Window('Process Killer', layout, keep_on_top=True, auto_size_buttons=False, default_button_element_size=(12, 1), return_keyboard_events=True, finalize=True) display_list = show_list_by_name(window) # ---------------- main loop ---------------- while True: # --------- Read and update window -------- event, values = window.read() if event in (None, 'Exit'): break # skip mouse, control key and shift key events entirely if 'Mouse' in event or 'Control' in event or 'Shift' in event: continue # --------- Do Button Operations -------- if event == 'Sort by Name': display_list = show_list_by_name(window) # psutil.cpu_percent(interval=.1) # procs = psutil.process_iter() # all_procs = [[proc.cpu_percent(), proc.name(), proc.pid] for proc in procs] # sorted_by_cpu_procs = sorted(all_procs, key=operator.itemgetter(1), reverse=False) # display_list = [] # for process in sorted_by_cpu_procs: # display_list.append('{:5d} {:5.2f} {}\n'.format(process[2], process[0]/10, process[1])) # window['-processes-'].update(display_list) elif event == 'Kill': processes_to_kill = values['-processes-'] for proc in processes_to_kill: pid = int(proc[0:5]) # if sg.popup_yes_no('About to kill {} {}'.format(pid, proc[12:]), keep_on_top=True) == 'Yes': try: kill_proc_tree(pid=pid) except: sg.popup_no_wait('Error killing process', auto_close_duration=1, auto_close=True) elif event == 'Sort by % CPU': psutil.cpu_percent(interval=.1) procs = psutil.process_iter() all_procs = [[proc.cpu_percent(), proc.name(), proc.pid] for proc in procs] sorted_by_cpu_procs = sorted(all_procs, key=operator.itemgetter(0), reverse=True) display_list = [] for process in sorted_by_cpu_procs: display_list.append('{:5d} {:5.2f} {}\n'.format( process[2], process[0] / 10, process[1])) window['-processes-'].update(display_list) else: # was a typed character if display_list is not None: new_output = [] for line in display_list: if values['-filter-'] in line.lower(): new_output.append(line) window['-processes-'].update(new_output) window.close()
pad=(0, 5), target='WATCHPATH'), sg.InputText(latest_watch_path, size=(95, 1), pad=((26, 2), 0), key='WATCHPATH', enable_events=True) ]] folder_list = [[ sg.Button('Refresh', font=('Futura', 18), size=(6, 1), pad=(3, (2, 5)), key='REFRESH') ], [sg.Listbox('', [], size=(30, 20), key='SOURCEPATHS')], [ sg.Listbox(preset_list, size=(30, 10), key='RENDERPRESET', default_values=latest_preset, enable_events=True, pad=(5, (15, 5))) ], [ sg.Checkbox('Custom only', key='CUSTOMPRESET', default=custom_preset_flag, font=('Futura', 15), enable_events=True), sg.Button('Queue',
imgs = [] names = [] for img in os.listdir(directory): imgs.append(os.path.join(directory, img)) file_counter = 0 for folder_name in os.listdir(screen_path): name = str(folder_name) names.append(name) print("Setting up GUI", flush=True) layout = [[gui.Text("What is this image?")], [gui.Image(imgs[0], key='image'), gui.Listbox(values=names, size=(25,55), key="list", enable_events=True), gui.Button("skip", size=(10,50))]] window = gui.Window("Wrong Sorter", layout) def remove_image(path): if os.path.exists(path): print("would remove", str(path)) #os.remove(path) def clear_directory(): global directory print("Cleaning up directories by deleting duplicates...", flush=True) for image in os.listdir(directory):
main_win = sg.Window('Хакатон', layout) while True: event1, values1 = main_win.read() if event1 in (None, 'Выход'): break elif event1 == 'Вывод' and not win2_active: win2_active = True main_win.Hide() layout2 = [[ sg.Text( 'Укажите в каких олимпиадах вы принимали участие и какие дипломы получили' ) ], [ sg.Listbox(values=get_pre_olymp(values1[1], values1[0]), size=(40, 12), key='-LIST-', enable_events=True) ], [sg.Button('Выход'), sg.Button('Далее')]] # Второе окно # Выбор заслуг и оценка сложности *в разработке* win2 = sg.Window('Список олимпиад', layout2) while True: event2, values2 = win2.Read() if event2 in (None, 'Выход'): win2.Close() win2_active = False main_win.UnHide() break
def Everything_NoContextManager(): form = sg.FlexForm('Everything bagel', default_element_size=(40, 1)) layout = [ [ sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25)) ], [sg.Text('Here is some text.... and a place to enter text')], [sg.InputText('This is my text')], [ sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True) ], [ sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1") ], [ sg.Multiline( default_text= 'This is the default Text should you decide not to type anything', size=(35, 3)), sg.Multiline(default_text='A second multi-line', size=(35, 3)) ], [ sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85) ], [ sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1') ], [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(), sg.Cancel()] ] button, values = form.LayoutAndRead(layout) del (form) sg.MsgBox('Title', 'The results of the form.', 'The button clicked was "{}"'.format(button), 'The values are', values)
def WINDOW_EXAMPLE(theme): sg.theme(theme) menu_def = [['&Application', ['E&xit', '&About']]] # Table Data data = [["John", 10], ["Jen", 5]] headings = ["Name", "Score"] input_layout = [ [sg.Menu(menu_def, key='-MENU-')], [sg.Text('Anything that requires user-input is in this tab!')], [sg.Input(key='-INPUT-')], [ sg.Slider(orientation='h', key='-SKIDER-'), sg.Image(data=sg.DEFAULT_BASE64_LOADING_GIF, enable_events=True, key='-GIF-IMAGE-'), ], [sg.Checkbox('Checkbox', default=True, k='-CB-')], [ sg.Radio('Radio1', "RadioDemo", default=True, size=(10, 1), k='-R1-'), sg.Radio('Radio2', "RadioDemo", default=True, size=(10, 1), k='-R2-') ], [ sg.Combo(values=('Combo 1', 'Combo 2', 'Combo 3'), default_value='Combo 1', readonly=True, k='-COMBO-'), sg.OptionMenu(values=('Option 1', 'Option 2', 'Option 3'), k='-OPTION MENU-'), ], [ sg.Spin([i for i in range(1, 11)], initial_value=10, k='-SPIN-'), sg.Text('Spin') ], [ sg.Multiline( 'Demo of a Multi-Line Text Element!\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nYou get the point.', size=(45, 5), k='-MLINE-') ], [ sg.Button('Button'), sg.Button('Popup'), sg.Button(image_data=sg.DEFAULT_BASE64_ICON, key='-LOGO-') ] ] asthetic_layout = [[ sg.T('Anything that you would use for asthetics is in this tab!') ], [sg.Image(data=sg.DEFAULT_BASE64_ICON, k='-IMAGE-')], [ sg.ProgressBar(1000, orientation='h', size=(20, 20), key='-PROGRESS BAR-'), sg.Button('Test Progress bar') ]] logging_layout = [[sg.Text("Anything printed will display here!")], [sg.Output(size=(60, 15), font='Courier 8')]] graphing_layout = [[ sg.Text("Anything you would use to graph will display here!") ], [ sg.Graph((200, 200), (0, 0), (200, 200), background_color="black", key='-GRAPH-', enable_events=True) ], [sg.T('Click anywhere on graph to draw a circle')], [ sg.Table(values=data, headings=headings, max_col_width=25, background_color='black', auto_size_columns=True, display_row_numbers=True, justification='right', num_rows=2, alternating_row_color='black', key='-TABLE-', row_height=25) ]] specalty_layout = [[ sg.Text("Any \"special\" elements will display here!") ], [sg.Button("Open Folder")], [sg.Button("Open File")]] theme_layout = [[ sg.Text( "See how elements look under different themes by choosing a different theme here!" ) ], [ sg.Listbox(values=sg.theme_list(), size=(20, 12), key='-THEME LISTBOX-', enable_events=True) ], [sg.Button("Set Theme")]] layout = [[ sg.Text('Demo Of (Almost) All Elements', size=(38, 1), justification='center', font=("Helvetica", 24), relief=sg.RELIEF_RIDGE, k='-TEXT HEADING-', enable_events=True) ]] layout += [[ sg.TabGroup([[ sg.Tab('Input Elements', input_layout), sg.Tab('Asthetic Elements', asthetic_layout), sg.Tab('Graphing', graphing_layout), sg.Tab('Specialty', specalty_layout), sg.Tab('Theming', theme_layout), sg.Tab('Output', logging_layout) ]], key='-TAB GROUP-') ]] return sg.Window('Gw2-RaidComp Pug', layout)
sg.Text('Temperatura'), sg.Slider(range=(-30, 80), orientation='h', size=(35, 20), default_value=0, key='_TEMP_') ], [ sg.Text('Humedad'), sg.Slider(range=(1000, 1200), orientation='h', size=(35, 20), default_value=1020, key='_HUM_') ], [sg.Button('Añadir', key='_ADD_', pad=((120, 5), 10))], [sg.Listbox(values=[], size=(35, 15), key='_LIST_', pad=(70, 10))], [sg.Input(key='_BROWSE_', enable_events=True, visible=False)], [ sg.FileBrowse('Guardar como...', target='_BROWSE_', file_types=(("JSON Files", "*.json"), )), sg.Button('Guardar', disabled=True, key='_SAVE_'), sg.Button('Cerrar') ]] window = sg.Window('TEMP GUI').Layout(layout) window.Finalize() while True: # Event Loop event, val = window.Read() #print(event, val)
def comp_window(theme): sg.theme(theme) menu_def = [['&Application', ['&About', 'E&xit']]] layout = [[sg.Menu(menu_def)], [ sg.Text('Compositions', size=(38, 1), justification='center', font=("Helvetica", 24), relief=sg.RELIEF_RIDGE) ]] # k = event tempstring = ", ".join(Compositions.keys()) layout2 = [[sg.Text("Default Compositions:")], [ sg.Listbox(values=list(Compositions.keys()), size=(20, 12), key="COMP_DEF", enable_events=True, select_mode="LISTBOX_SELECT_MODE_SINGLE"), sg.Output(size=(55, 12), key="OUTPUT_DEF", echo_stdout_stderr=False) ], [sg.HorizontalSeparator()]] layout3 = [[sg.HorizontalSeparator()]] # se customly dodane layout4 = [[sg.Text("Custom Compositions:")], [ sg.Listbox(values=list(CustomCompositions.keys()), size=(20, 12), key="COMP_CUSTOM", enable_events=True, select_mode="LISTBOX_SELECT_MODE_SINGLE"), sg.Text("\t"), sg.Button(button_text="Add a custom composition", size=(13, 2), button_color="white"), sg.Button(button_text="Delete a custom composition", k="DeleteComp", size=(13, 2), button_color="gray"), sg.Button(button_text="Back", k="Menu", size=(13, 2), button_color="orange") ]] layout5 = [[sg.Text("Custom Compositions:")], [ sg.Button(button_text="Add a custom composition", size=(13, 2), button_color="white"), sg.Button(button_text="Delete a custom composition", k="DeleteComp", size=(13, 2), button_color="gray"), sg.Button(button_text="Back", k="Menu", size=(13, 2), button_color="orange") ]] layout += layout2 + layout3 if list(CustomCompositions.keys()) != []: layout += layout4 else: layout += layout5 return sg.Window('Gw2-RaidComp Compositions', layout, font=14)
def main(nivel='',tiempo= 0,carga='',actual={}): temaNivel(nivel) colIzq = [[sg.Button(puntaje_casillero(i,j,nivel,naranja,verde,azul,rojo),button_color=calcular(i,j,naranja,verde,azul,rojo,nivel),size=(5, 2), key=(i,j), pad=(0,0)) for j in range(1,16)] for i in range(1,16)] colDer =[ [sg.Text('Computadora:',size =(100,None),justification='left',text_color='yellow')], [sg.Button('?',button_color=color_button,size=tam_button, key=(100,i+1))for i in range(7)], [sg.Text('______________________________________________________',text_color='red')], [sg.Text('puntaje Computadora:'),sg.In(0, key=(40,40),text_color='black',size=tam_button,disabled = True)], [sg.Text('Lista de palabras ubicadas de la computadora:')], [sg.Listbox(values=[], size= (20,4),key='listaComp',font=('Helvetica', 10))], [sg.Text('')], [sg.Text('nivel: '),sg.In('', key=(50,50),text_color='black',size=(24,2),disabled = True)], [sg.Text('palabras a buscar:'),sg.In('', key=(60,60),text_color='black',size= (24,2),disabled = True)], [sg.Text("Fichas restantes: "),sg.In(0, key=(20,20),text_color='black',size=(24,2),disabled = True)], [sg.Text('')], [sg.Text('Tiempo:'),sg.Text('', size=(8, 1), font=('Helvetica', 20),justification='center', key='text')], [sg.Text('Lista de palabras ubicadas del jugador:')], [sg.Listbox(values=[], size= (20,4),key='listaJug',font=('Helvetica', 10))], [sg.Text('cantidad de cambios:'),sg.In(0, key=(70,70),text_color='black',size=(2,2),disabled = True)], [sg.Text('puntaje Jugador:'),sg.In(0, key=(30,30),text_color='black',size=tam_button,disabled = True)], [sg.Text('______________________________________________________',text_color='red')], [sg.Text('Jugador:',size =(100,None),justification='left',text_color='yellow')], [sg.Button('',button_color=color_button,size=tam_button, key=(0,i+1))for i in range(7)]] colDer.append([sg.Button('Evaluar', key=(0,8),button_color=('black','gray'),size=tam_button),sg.Button('Cambiar Fichas', key=(0,11),button_color=('black','gray'),size=(6,2)),sg.Button('Devolver Fichas', key=(0,9),button_color=('black','gray'),size=(6,2)),sg.Button('Pasar', key=(0,10),button_color=('black','gray'),size=tam_button),sg.Button('Guardar partida', key=(0,12),button_color=('black','gray'),size=(7,2)),sg.Button('Terminar Partida', key=(0,13),button_color=('black','gray'),size=(7,2))]) layout = [[sg.Column(colIzq,size=(750,750)),sg.Column(colDer,size=(700,700))]] window = sg.Window('Scrabble',layout).Finalize() window.Maximize() ScrDic = {} crearDicTablero(window,ScrDic,nivel) valor_A = '' valor_B = '' fichasComp={} listaPalJug = [] listaPalComp = [] def mostrar_listado(listbox, lista): listbox.Update(map(lambda x: "{}".format(x), lista)) #------------------------------------------------------------------------------------------------------ if carga != 'nuevo':#<--- si no es distinto de '', significa que se cargo la partida tiempo= actual['TiempoTotal'] resta= actual['Tiempo'] clasificacionAleatoria = actual['clasificacionAleatoria'] cantCambFichas = actual['cantCambFichas'] window[(70,70)].update(cantCambFichas) puntJueg = actual['puntJueg'] totalJug= actual['PuntajeJug'] window[(30,30)].update(totalJug) totalComp= actual['PuntajeComp'] window[(40,40)].update(totalComp) consonantes=actual['ConsonantesFichas'] vocales=actual['VocalesFichas'] window[(60,60)].update(clasificacionAleatoria) window[(20,20)].update(sum(actual['ConsonantesFichas'].values()) + sum(actual['VocalesFichas'].values())) botones = {} for i in range(7): window[0,i+1].update(actual['FichasAtrilJug'][i]) fichasComp[100,i+1]=actual['FichasAtrilComp'][i] botones[0,i+1] = actual['FichasAtrilJug'][i] for i in range(len(actual['ClavesCasillero'])): clave= actual['ClavesCasillero'][i]#<--obtengo la clave del casillero coordenada=tuple((map(int,clave.split(','))))#<--convierto la clave que estaba en string a tupla ScrDic[coordenada]=actual[actual['ClavesCasillero'][i]]#<--guardo en el diccionario los datos de ese casillero window[coordenada].update(ScrDic[coordenada]['letra'], button_color=ScrDic[coordenada]['colorLetraUbi'],disabled_button_color=ScrDic[coordenada]['colorLetraUbi'],disabled=True)#<--coloco la letra en la interfaz else:#<--- sino, inicia una nueva cantCambFichas = 3 window[(70,70)].update(cantCambFichas) resta= 0 tiempo=tiempo * 6000 consonantes = actual['cantidad'] vocales={'A':0,'E':0,'I':0,'O':0,'U':0} for i in vocales.keys(): vocales[i]=consonantes[i] del consonantes[i] puntJueg = actual['valor'] botones = {(0,1):fichas(consonantes,vocales,1),(0,2):fichas(consonantes,vocales,2),(0,3):fichas(consonantes,vocales,3),(0,4):fichas(consonantes,vocales,4),(0,5):fichas(consonantes,vocales,5),(0,6):fichas(consonantes,vocales,6),(0,7):fichas(consonantes,vocales,7)} if nivel == 'Dificil':#<--- si el nivel es dificil toma aleatoriamente un valor(verbo,sustantivo, adjetivo) listaClasif = ['VB','NN','JJ'] clasificacionAleatoria = random.choice(listaClasif) if(clasificacionAleatoria == 'VB'): opcion ='verbos' elif(clasificacionAleatoria == 'NN'): opcion ='sustantivos' else: opcion ='adjetivos' window[(60,60)].update(opcion) else:# si no, deja la variable vacia if nivel == 'Facil': clasificacionAleatoria = 'verbos,sustantivos,adjetivos' else: clasificacionAleatoria = 'verbos,sustantivos' window[(60,60)].update(clasificacionAleatoria) for i in range(7): window[0,i+1].update(botones[0,i+1]) fichasComp[100,i+1]=fichas(consonantes,vocales,i+1) window[(20,20)].update(sum(consonantes.values()) + sum(vocales.values())) totalJug=0#<--- puntaje total del jugador totalComp =0#<------- puntaje total de la computadora listaTurno=['comp','jug'] eleccion = random.choice(listaTurno) if eleccion == 'comp': activar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13)) palabras_existentes= turnoComputadora.turno(clasificacionAleatoria,fichasComp,nivel) if len(palabras_existentes) == 0:#<--- si la computadora no tiene palabras y hay mas fichas,las cambia sg.popup('la computadora no encontro palabra') else: palabraUbi,encontro,listaCoorLetrasUbicadas = turnoComputadora.buscarTablero(palabras_existentes,ScrDic) if not encontro: #<---- si la computadora no encontro lugar y hay mas fichas,cambia las fichas turnoComputadora.cambiarFichas(fichasComp,consonantes,vocales,window) sg.popup('la computadora no encontro ubicacion') else: sumaComp= turnoComputadora.sumarPuntaje(window,listaCoorLetrasUbicadas,ScrDic,puntJueg) #----------------------------------------- listaPalComp.append(palabraUbi.lower()) mostrar_listado( window.FindElement('listaComp'), listaPalComp) #----------------------------------------- turnoComputadora.nuevasFichas(palabraUbi,fichasComp,window,consonantes,vocales) window[(20,20)].update(sum(consonantes.values()) + sum(vocales.values()))#con esto puedo sumar para ver si el diccionario no tiene fichas totalComp = totalComp + sumaComp window[(40,40)].update(totalComp) listaCoorLetrasUbicadas = [] #----activa evaluar y cambiar fichas desactivar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13)) window[(50,50)].update(nivel) guardado ={}#<--- guarda la ubicacion y la letra en donde se ubico la ficha en el tablero guardadoAtril = []#<---- guarda las coordenadas del atril del jugador: de las fichas que uso palabra = []#<----guarda las letras de la palabra ubicacion = []#<---guarda las coordenadas de donde se ubicaron las letras en el tablero listaCoorLetrasUbicadas = []#<---- es la lista de las coordenadas donde la computadora ubico la palabra en el tablero Termino = False#<--- si da true es porque seguirJ es igual a false, lo evalua cuando de apreta pasar listaVocal=['A','E','I','O','U']#<--- es una lista de de vocales que uso para comparar current_time = 0 start_time = time_as_int() - resta#<--- con esto empiezo desde el tiempo en que me quede while True: event, values = window.read(timeout=10) current_time = time_as_int() - start_time if current_time >= tiempo:#<-- esto corta el programa a los 60 segundos evaluarGanador(totalJug,totalComp,nivel) break if Termino:#<---- si estos dos son false, ya no se puede seguir jugando evaluarGanador(totalJug,totalComp,nivel) break if event in (None, 'Exit'): break elif event != (0,8) and event != (0,9) and event != (0,10) and event != (0,11) and event != (0,12) and event != (0,13):#<--------si no es evaluar,modificar,pasar if event in botones.keys():#<------entra si se apreto los botones del atril valor_A = window[event].GetText()#<----toma la letra del boton del atril window[event].update('', button_color = color_button) activar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13)) if window[(8,8)].GetText() == 'Px3':#<------si no hay ficha en el casillero del medio window[(8,8)].update(valor_A, disabled_button_color=('white','black'), button_color=('white','black'),disabled=True)#<--- window[event].update(text='') ubicacion.append((8,8)) guardadoAtril.append(event) guardado[(8,8)] = valor_A desactivar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13)) else: keys_entered = event#<--- guarda el event event, values = window.read() if event in (None, 'Exit'):#<--------en caso de se haya apretado un boton del atril y se cierre break elif event not in botones.keys():#<-------si no es un boton del atril valor_B = window[event].GetText()#<----toma la letra del segundo event if valor_B == '' or valor_B == 'Px2' or valor_B == 'Px3' or valor_B == 'Lx2' or valor_B == 'Lx3' or valor_B == 'Des1' or valor_B == 'Des2' or valor_B == 'Des3':#<---probando px2 window[event].update(valor_A, disabled_button_color=('white','black'), button_color=('white','black'),disabled=True)#<--- window[keys_entered].update(text='') ubicacion.append(event) guardadoAtril.append(keys_entered) guardado[event] = valor_A desactivar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13)) elif event == (0,8):#<----apreto evaluar if len(ubicacion) == 0: sg.popup('no coloco ninguna ficha en el tablero, no se puede evaluar') elif len(ubicacion) == 1: sg.popup('debe colocar 2 fichas minimo, no se puede evaluar') turnoJugador.devolverAtril(ubicacion,window,ScrDic,guardadoAtril,botones) else: incorrecto,ubicacion= turnoJugador.evaluarUbi(ubicacion) if incorrecto:#<---- si es incorrecto por ubicacion, vuelve las fichas al lugar turnoJugador.devolverAtril(ubicacion,window,ScrDic,guardadoAtril,botones) else: for i in ubicacion:#<---- utilizo las ubicaciones ordenadas, para sacar la palabra palabra.append(guardado[i]) strPal=''.join(palabra).lower()#<-----transformo la lista en string if clasificar(strPal,nivel,clasificacionAleatoria): for i in ubicacion: window[i].update(disabled_button_color=('white','black'),disabled=True) sg.popup('se ubico la palabra') totalJug = turnoJugador.sumoPalabra(ubicacion,ScrDic,palabra,puntJueg,totalJug,window) listaPalJug.append(strPal) mostrar_listado( window.FindElement('listaJug'), listaPalJug) turnoJugador.pidoFichasNuevas(guardadoAtril,botones,consonantes,vocales,window) if any(botones[i] == '' for i in botones.keys()): Termino=True #---desactiva evaluar y cambiar fichas activar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,11),(0,12),(0,13)) else: sg.popup('la palabra no es correcta,vuelva a intentarlo') turnoJugador.devolverAtril(ubicacion,window,ScrDic,guardadoAtril,botones) palabra=[] guardado,guardadoAtril,ubicacion=turnoJugador.vaciar() elif event == (0,9):#modificar #devolver la fichas al atril,en caso de que te hayas equivocado antes de evaluar la palabra turnoJugador.devolverAtril(ubicacion,window,ScrDic,guardadoAtril,botones) guardado,guardadoAtril,ubicacion=turnoJugador.vaciar() elif event == (0,11):#<----cambio las fichas if len(ubicacion) != 0: turnoJugador.devolverAtril(ubicacion,window,ScrDic,guardadoAtril,botones) guardado,guardadoAtril,ubicacion=turnoJugador.vaciar() #---------------------------------------- if cantCambFichas != 0: sg.popup('haga click en las fichas que quiera cambiar y luego haga click en cambiar fichas') listaDisabled=[] for i in range(1,16): for j in range(1,16): if window[(i,j)].GetText() not in puntJueg.keys(): listaDisabled.append((i,j)) activar(window,(0,8),(0,9),(0,10),(0,12),(0,13),listaDisabled) event, values = window.read() listaFcambiar= [] while event !=(0,11):#se guarda en una lista las coordenadas de las fichas que quiere cambiar el jugador listaFcambiar.append(event) window[event].update(disabled = True) event, values = window.read() activar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,11)) desactivar(window,(0,10),(0,12),(0,13),listaDisabled) for i in listaFcambiar: if botones[i] in listaVocal: if botones[i] in vocales: vocales[botones[i]] = vocales[botones[i]] + 1 else: vocales[botones[i]] = 1 else: if botones[i] in consonantes: consonantes[botones[i]] = consonantes[botones[i]] + 1 else: consonantes[botones[i]] = 1 botones[i]=fichas(consonantes,vocales,i[1]) window[i].update(text= botones[i]) cantCambFichas = cantCambFichas - 1 window[(70,70)].update(cantCambFichas) else: sg.popup('ya utilizo los 3 cambios de fichas') elif event == (0,12):#guardar partida if len(ubicacion) != 0: turnoJugador.devolverAtril(ubicacion,window,ScrDic,guardadoAtril,botones) guardado,guardadoAtril,ubicacion=turnoJugador.vaciar() guardarP(window,totalJug,totalComp,consonantes,vocales,nivel,current_time,tiempo,clasificacionAleatoria,ScrDic,cantCambFichas,puntJueg,fichasComp) break elif event == (0,13):#terminar partida evaluarGanador(totalJug,totalComp,nivel) break else: if len(ubicacion) != 0: turnoJugador.devolverAtril(ubicacion,window,ScrDic,guardadoAtril,botones) guardado,guardadoAtril,ubicacion=turnoJugador.vaciar() palabras_existentes= turnoComputadora.turno(clasificacionAleatoria,fichasComp,nivel) #----------------------------------------------------------------------- if len(palabras_existentes) == 0 and (sum(consonantes.values()) + sum(vocales.values())) == 0:#<--- si la computadora no tiene palabras y no hay mas fichas,no puede seguir Termino=True elif len(palabras_existentes) == 0:#<--- si la computadora no tiene palabras y hay mas fichas,las cambia turnoComputadora.cambiarFichas(fichasComp,consonantes,vocales,window) sg.popup('la computadora no encontro palabra') else:#<---sino, busca la ubicacion en el tablero palabraUbi,encontro,listaCoorLetrasUbicadas = turnoComputadora.buscarTablero(palabras_existentes,ScrDic) #-------------------------------------------------------------------------------------------------- if not encontro and (sum(consonantes.values()) + sum(vocales.values())) == 0:#<--- si la computadora no encontro lugar y no hay mas fichas,no puede seguir Termino=True elif not encontro: #<---- si la computadora no encontro lugar y hay mas fichas,cambia las fichas turnoComputadora.cambiarFichas(fichasComp,consonantes,vocales,window) sg.popup('la computadora no encontro ubicacion') else:#<------ sino, encontro lugar y la ubica en la interfaz sumaComp= turnoComputadora.sumarPuntaje(window,listaCoorLetrasUbicadas,ScrDic,puntJueg) #----------------------------------------------------------------------------------------------- listaPalComp.append(palabraUbi.lower()) mostrar_listado( window.FindElement('listaComp'), listaPalComp) #--------------------------------------------------------------------------------- turnoComputadora.nuevasFichas(palabraUbi,fichasComp,window,consonantes,vocales) if any(fichasComp[i] == '' for i in fichasComp.keys()): Termino=True #-------------------------------------------------------------- window[(20,20)].update(sum(consonantes.values()) + sum(vocales.values()))#con esto puedo sumar para ver si el diccionario no tiene fichas totalComp = totalComp + sumaComp window[(40,40)].update(totalComp) listaCoorLetrasUbicadas = [] #----activa evaluar y cambiar fichas desactivar(window,(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13)) window['text'].update('{:02d}:{:02d}'.format((current_time // 100) // 60,(current_time // 100) % 60)) window.close()
def make_window(): """ Creates the main window :return: The main window object :rtype: (Window) """ theme = get_theme() editor = get_editor() demo_files_dict = get_demo_git_files() if not theme: theme = sg.OFFICIAL_PYSIMPLEGUI_THEME sg.theme(theme) # First the window layout...2 columns find_tooltip = "Find in file\nEnter a string in box to search for string inside of the files.\nFile list will update with list of files string found inside." filter_tooltip = "Filter files\nEnter a string in box to narrow down the list of files.\nFile list will update with list of files with string in filename." ML_KEY = '-ML-' # Multline's key left_col = [[ sg.Listbox(values=list(demo_files_dict.keys()), select_mode=sg.SELECT_MODE_EXTENDED, size=(40, 20), key='-DEMO LIST-') ], [ sg.Text('Filter:', tooltip=filter_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FILTER-', tooltip=filter_tooltip), sg.T(size=(20, 1), k='-FILTER NUMBER-') ], [sg.Button('Run'), sg.B('Edit'), sg.B('Clear')], [ sg.Text('Find:', tooltip=find_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FIND-', tooltip=find_tooltip), sg.T(size=(20, 1), k='-FIND NUMBER-') ]] right_col = [ [ sg.Multiline(size=(70, 21), write_only=True, key=ML_KEY, reroute_stdout=True, echo_stdout_stderr=True) ], [ sg.Button('Edit Me (this program)'), sg.B('Settings'), sg.Button('Exit') ], [ sg.T('PySimpleGUI ver ' + sg.version.split(' ')[0] + ' tkinter ver ' + sg.tclversion_detailed, font='Default 8', pad=(0, 0)) ], ] # ----- Full layout ----- layout = [[ sg.Text('PySimpleGUI Project File Searcher & Launcher', font='Any 20') ], [sg.T('Click settings to set top of your tree')], sg.vtop([ sg.Column(left_col, element_justification='c'), sg.Col(right_col, element_justification='c') ])] # --------------------------------- Create Window --------------------------------- window = sg.Window('PSG Finder Launcher', layout) sg.cprint_set_output_destination(window, ML_KEY) return window
key='_column_', enable_events=True), sg.T('First Row:'), sg.I(default_text='5', size=(4, None), key='_firstrow_', enable_events=True), sg.T('Last Row:'), sg.I(default_text='8', size=(4, None), key='_lastrow_', enable_events=True) ], # Row 4 - file display [ sg.Listbox(values="", size=(54, 10), key="_file_list_"), sg.VerticalSeparator(), audio_table ], # Row 5 - Distance and output file [ sg.Text('Distance between files (in multiples of length):'), sg.I(default_text='2', size=(3, None), key='_distance_'), sg.Text(" " * 22), sg.Text('Output file:'), sg.Input(key='_output_file_', size=(30, 1), default_text=st.gui_default_output_path), sg.FileSaveAs(file_types=(('ALL Files', '*.*'), ('Reaper project', '*.RPP'))) ], # Row 6 - Generate
], [ sg.Multiline( default_text= 'This is the default Text shoulsd you decide not to type anything', ) ], [ sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85) ], [ sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10) ], [sg.Text('_' * 100, size=(70, 1))], [sg.Text('Choose Source and Destination Folders', size=(35, 1))], [
ettv=values[9]) download_links = [] [download_links.append(i) for i in dict_download_links.keys()] results_layout = [[sg.Text("\n", font=("Segoe UI Light", 5))], [ sg.Text("Process finished sucessfully!", font=("Segoe UI Light", 14), size=(30, 0), justification="left") ], [sg.Text("\n", font=("Segoe UI Light", 1))], [ sg.Listbox(values=download_links, size=(90, 15), font=("Segoe UI", 10), enable_events=True) ], [sg.Text("\n", font=("Segoe UI Light", 1))], [ sg.Text(" " * 16), sg.Button("Save all links to file", size=(22, 0), font=("Segoe UI Light", 10, "bold")), sg.Button("Open magnet link", size=(16, 0), font=("Segoe UI Light", 10, "bold")), sg.Button("Copy magnet link", size=(16, 0), font=("Segoe UI Light", 10, "bold")), sg.Button("Close", size=(12, 0),
[sg.Text('Here is some text.... and a place to enter text')], [sg.InputText('This is my text')], [sg.Frame(layout=[ [sg.CBox('Checkbox', size=(10, 1)), 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', title_color='red', 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'), 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)), sg.Frame('Labelled Group', [[ sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25, tick_interval=25), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), sg.Col(column1, background_color='lightblue')]]) ], [sg.Text('_' * 80)], [sg.Text('Choose A Folder', size=(35, 1))], [sg.Text('Your Folder', size=(15, 1), justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse()], [sg.Submit(tooltip='Click to submit this form'), sg.Cancel()]] window = sg.Window('Everything bagel', layout, default_element_size=(40, 1), grab_anywhere=False)
import PySimpleGUI as sg """ Allows you to "browse" through the Theme settings. Click on one and you'll see a Popup window using the color scheme you chose. It's a simple little program that also demonstrates how snappy a GUI can feel if you enable an element's events rather than waiting on a button click. In this program, as soon as a listbox entry is clicked, the read returns. """ sg.theme('Dark Brown') layout = [[sg.Text('Theme Browser')], [sg.Text('Click a Theme color to see demo window')], [ sg.Listbox(values=sg.theme_list(), size=(20, 12), key='-LIST-', enable_events=True) ], [sg.Button('Exit')]] window = sg.Window('Theme Browser', layout) while True: # Event Loop event, values = window.read() if event in (sg.WIN_CLOSED, 'Exit'): break sg.theme(values['-LIST-'][0]) sg.popup_get_text('This is {}'.format(values['-LIST-'][0])) window.close()
else: genes_names_list, network_dictionary, unused_genes, network_as_list, genes_non_sort = ImportBooleanModel( genes_list_filename, network_filename) # Columns layout for the batch mode window col_batch1 = [ [ sg.Text('Input : List of genes', text_color='#e4e4e4', background_color='#343434') ], [ sg.Listbox( values=genes_names_list, select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20, 35), tooltip= 'Highlighted genes will be set to 1 at the start of each simulation run if the choice of genes initial states parameter is << specified >>' ) ], ] col_batch2 = [ [ sg.Text('Input : Interactions in the network', text_color='#e4e4e4', background_color='#343434') ], [ sg.Listbox( values=network_as_list,
import sqlite3 con = sqlite3.connect('DataPay') cursor = con.cursor() ListHistory = [] index = 0 inp = [[ sg.InputCombo(('Продукты', 'Одежда', 'ГОС Услуги', 'Питание', 'Развлечения', 'Транспорт', 'Другое'), size=(12, 1), key='_CATALOG_'), sg.InputText('', key='_DATA_', size=(20, 1)), sg.Button('Add', button_color=('white', 'green')) ], [sg.Listbox(values=(), key='_LISTBOX_', size=(40, 5))]] layout = [[ sg.Graph(canvas_size=(200, 240), graph_bottom_left=(-105, -105), graph_top_right=(105, 105), background_color='gray18', key='graph', tooltip='This is a cool graph!'), sg.Column(inp, background_color="gray18") ]] window = sg.Window('FIMA', layout, grab_anywhere=True, background_color='gray16').Finalize() graph = window.Element('graph')
def layoutBooleanModelVisu(): col_visu1 = [ [ sg.Text('Input : List of genes', text_color='#e4e4e4', background_color='#343434') ], [ sg.Listbox( values=genes_names_list, select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20, 35), tooltip= 'Highlighted genes will be set to 1 at the start of each simulation run if the choice of genes initial states parameter is << specified >>' ) ], ] col_visu2 = [ [ sg.Text('Input : Interactions in the network', text_color='#e4e4e4', background_color='#343434') ], [ sg.Listbox( values=network_as_list, select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(30, 35), tooltip= 'Format is [Source gene, interaction (-1: repression, 1 : activation), target gene]' ) ], ] # col_subbatch3 = [[sg.Listbox(values=model_type_list, select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(15, 4), # tooltip='Highlight the models to run through ARGOS'), # sg.Listbox(values=boundary_model_list, select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(15, 4), # tooltip='Highlight the models to run through ARGOS')]] col_visu3 = [[ sg.Frame(layout=[ [ sg.Text( 'Model type', text_color='#e4e4e4', background_color='#343434', tooltip='Choice of rules to apply to the network structure' ), sg.Combo(values=model_type_list, default_value=model_type_list[0]) ], [ sg.Text( 'Boundary conditions', text_color='#e4e4e4', background_color='#343434', tooltip='Choice of behavior for nodes without regulators'), sg.Combo(values=boundary_model_list, default_value=boundary_model_list[0]) ], [ sg.Text( 'Genes initial states', text_color='#e4e4e4', background_color='#343434', tooltip= 'In <<specified>> mode, use the gene list panel to highlight the genes to be set to 1 at start,\n all other genes will be set to 0 (0 or 1 in <<random-specified>> mode)' ), sg.Combo(values=initial_states_choice_list, default_value=initial_states_choice_list[0]) ], [ sg.Text( 'Number of initial states :', text_color='#e4e4e4', background_color='#343434', tooltip= 'Choice of how many initial states the model will run from' ), sg.Radio('All possible states', 'RADIO2', background_color='#343434', text_color='#e4e4e4'), sg.Radio('Given number of states', 'RADIO2', background_color='#343434', text_color='#e4e4e4', default=True), sg.InputText(size=(10, 1), default_text='1') ], [ sg.Text( 'KO mutation type', text_color='#e4e4e4', background_color='#343434', tooltip= 'Choice of Knocked Out mutation to apply to the network \n- single KO will run the model mutating each chosen genes one at a time' '\n- multiple KO will run the model once with all chosen genes as KO' '\n- combination KO will go through all combinations of double KO for the chosen genes and run the model for each' ), sg.Combo(values=KO_mutation_type_list, default_value=KO_mutation_type_list[0]) ], [ sg.Text( 'List of KO genes', text_color='#e4e4e4', background_color='#343434', tooltip= 'Enter gene names separated by a colon e.g. ABC, LMN, XYZ' ), sg.InputText() ], [ sg.Text( 'OA mutation type', text_color='#e4e4e4', background_color='#343434', tooltip= 'Choice of Over Activated mutation to apply to the network \n- single OA will run the model mutating each chosen genes one at a time' '\n- multiple OA will run the model once with all chosen genes as KO' '\n- combination OA will go through all combinations of double KO for the chosen genes and run the model for each' ), sg.Combo(values=OA_mutation_type_list, default_value=OA_mutation_type_list[0]) ], [ sg.Text( 'List of OA genes', text_color='#e4e4e4', background_color='#343434', tooltip= 'Enter gene names separated by a colon e.g. ABC, LMN, XYZ' ), sg.InputText() ], [sg.Button('Run HELIOS')] ], title='Predict System Fates', title_color='#e4e4e4', background_color='#343434', relief=sg.RELIEF_GROOVE) ], [ sg.Frame(layout=[[ sg.Text('Source', text_color='#e4e4e4', background_color='#343434', tooltip='Value must a number'), sg.InputText(size=(10, 1)), sg.Text( 'Interaction', text_color='#e4e4e4', background_color='#343434', tooltip='1 for activation or -1 for inhibition'), sg.InputText(size=(10, 1)), sg.Text('Target', text_color='#e4e4e4', background_color='#343434', tooltip='Value must a '), sg.InputText(size=(10, 1)), sg.Button('Add element') ]], title='Add element to graph', title_color='#e4e4e4', background_color='#343434', relief=sg.RELIEF_GROOVE) ], [ sg.Frame(layout=[[ sg.Button('Add element from CSV'), sg.Input(), sg.FileBrowse() ]], title='Add element from CSV', title_color='#e4e4e4', background_color='#343434', relief=sg.RELIEF_GROOVE) ], [ sg.Frame(layout=[[ sg.Input(), sg.FileBrowse(), sg.Button("Load") ]], title='Load saved graph', title_color='#e4e4e4', background_color='#343434', relief=sg.RELIEF_GROOVE) ], [sg.Text('', background_color='#343434')]] layout_visu = [[ sg.Column(col_visu1, background_color='#343434'), sg.Column(col_visu2, background_color='#343434'), sg.Column(col_visu3, background_color='#343434') ], [ sg.Text('Extract core network :', text_color='#e4e4e4', background_color='#343434') ], [sg.Exit()]] window_visu = sg.Window("Initialize Network", alpha_channel=0.95, layout=layout_visu) return window_visu
search_layout = [ [ sg.Text("Enter the folder you want to search:", key="search_label", visible=True), sg.InputText(key="search_input", disabled=False, visible=True), sg.FolderBrowse(key="search_folder", visible=True) ], [ sg.Text("Enter keywords to search", key="keywords", visible=True), sg.InputText(key="keywords_input", visible=True), sg.Checkbox("Match Whole", key="match_whole") ], [ sg.Button("Search", key="search_btn", button_color=("white", "green")), sg.Text("Searched 10/10 files", key="count", visible=False) ], [ # sg.Text("File : "), sg.Text(key='found_file'), sg.Button("Open file", button_color=("white", "blue")) sg.Listbox([":)"], key="Files", size=(50, 3), visible=True), sg.Button("Open", key="Open", button_color=("white", "green"), visible=False) ] ] search_window = sg.Window("Search Files", resizable=False).Layout(search_layout)
sg.Text('Menu de Juegos', size=(15, 1), justification='center', font=("Fixedsys", 25)) ], [ sg.Text('-Por favor ingrese sus datos: ', justification='center', font=('Fixedsys')) ], [ sg.Text('Usuario: ', font=('Fixedsys'), justification='center'), sg.Input(key='usuario') ], [sg.Text('Edad: ', font=('Fixedsys')), sg.Input(key='edad')], [sg.Text('Email: ', font=('Fixedsys')), sg.Input(key='email')], [sg.Text('Contrasena: ', font=('Fixedsys')), sg.Input(key='contra')], [ sg.Text( '-Si ya tiene su usuario ingresado puede seleccionar\nun juego y continuar!', font=('Fixedsys')) ], [sg.Listbox(juegos, size=(15, len(juegos)), key='juego')], [sg.Submit(), sg.Cancel()] ] if __name__ == '__main__': import sys sys.exit(main(sys.argv))
def make_window(): """ Creates the main window :return: The main window object :rtype: (Window) """ theme = get_theme() if not theme: theme = sg.OFFICIAL_PYSIMPLEGUI_THEME sg.theme(theme) # First the window layout...2 columns find_tooltip = "Find in file\nEnter a string in box to search for string inside of the files.\nFile list will update with list of files string found inside." filter_tooltip = "Filter files\nEnter a string in box to narrow down the list of files.\nFile list will update with list of files with string in filename." find_re_tooltip = "Find in file using Regular Expression\nEnter a string in box to search for string inside of the files.\nSearch is performed after clicking the FindRE button." left_col = sg.Column([ [ sg.Listbox(values=get_file_list(), select_mode=sg.SELECT_MODE_EXTENDED, size=(50, 20), bind_return_key=True, key='-DEMO LIST-') ], [ sg.Text('Filter (F1):', tooltip=filter_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FILTER-', tooltip=filter_tooltip), sg.T(size=(15, 1), k='-FILTER NUMBER-') ], [sg.Button('Run'), sg.B('Edit'), sg.B('Clear'), sg.B('Open Folder')], [ sg.Text('Find (F2):', tooltip=find_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FIND-', tooltip=find_tooltip), sg.T(size=(15, 1), k='-FIND NUMBER-') ], ], element_justification='l', expand_x=True, expand_y=True) lef_col_find_re = sg.pin( sg.Col([[ sg.Text('Find (F3):', tooltip=find_re_tooltip), sg.Input(size=(25, 1), key='-FIND RE-', tooltip=find_re_tooltip), sg.B('Find RE') ]], k='-RE COL-')) right_col = [ [ sg.Multiline(size=(70, 21), write_only=True, key=ML_KEY, reroute_stdout=True, echo_stdout_stderr=True) ], [ sg.Button('Edit Me (this program)'), sg.B('Settings'), sg.Button('Exit') ], [ sg.T('PySimpleGUI ver ' + sg.version.split(' ')[0] + ' tkinter ver ' + sg.tclversion_detailed, font='Default 8', pad=(0, 0)) ], [sg.T('Python ver ' + sys.version, font='Default 8', pad=(0, 0))], ] options_at_bottom = sg.pin(sg.Column([[ sg.CB('Verbose', enable_events=True, k='-VERBOSE-'), sg.CB('Show only first match in file', default=True, enable_events=True, k='-FIRST MATCH ONLY-'), sg.CB('Find ignore case', default=True, enable_events=True, k='-IGNORE CASE-'), sg.CB('Wait for Runs to Complete', default=False, enable_events=True, k='-WAIT-') ]], pad=(0, 0), k='-OPTIONS BOTTOM-', expand_x=True, expand_y=False), expand_x=True, expand_y=False) choose_folder_at_top = sg.pin( sg.Column([[ sg. T('Click settings to set top of your tree or choose a previously chosen folder' ), sg.Combo(sorted(sg.user_settings_get_entry('-folder names-', [])), default_value=sg.user_settings_get_entry( '-demos folder-', ''), size=(50, 30), key='-FOLDERNAME-', enable_events=True, readonly=True) ]], pad=(0, 0), k='-FOLDER CHOOSE-')) # ----- Full layout ----- layout = [[ sg.Text('PySimpleGUI Demo Program & Project Browser', font='Any 20') ], [choose_folder_at_top], [ sg.Column([[left_col], [lef_col_find_re]], element_justification='l', expand_x=True, expand_y=True), sg.Column(right_col, element_justification='c', expand_x=True, expand_y=True) ], [options_at_bottom]] # --------------------------------- Create Window --------------------------------- window = sg.Window('PSG Demo & Project Browser', layout, finalize=True, icon=icon, resizable=True) window['-DEMO LIST-'].expand(True, True, True) window[ML_KEY].expand(True, True, True) window.bind('<F1>', '-FOCUS FILTER-') window.bind('<F2>', '-FOCUS FIND-') window.bind('<F3>', '-FOCUS RE FIND-') if not advanced_mode(): window['-FOLDER CHOOSE-'].update(visible=False) window['-RE COL-'].update(visible=False) window['-OPTIONS BOTTOM-'].update(visible=False) sg.cprint_set_output_destination(window, ML_KEY) return window