def openWindowImageSearch(): print('Image search') ROOT_DIR = os.path.dirname( os.path.abspath(__file__))[0:-7] + "\\data\\blohsaved.png" print(ROOT_DIR) image_elem = sg.Image(ROOT_DIR) layoutOperation = [[ sg.Text('An image says what a thousand words can\'t..') ], [sg.Text('The image :'), sg.InputText('path'), sg.FileBrowse()], [image_elem], [sg.Button('Search for me'), sg.Button('Cancel')]] windowOperation = sg.Window('Text it out').Layout(layoutOperation) while True: eventOperation, valuesOperation = windowOperation.Read(timeout=50) if eventOperation in (None, 'Cancel'): windowOperation.close() main() break elif eventOperation in ('Search for me'): windowOperation.close() searchByImageAlgorithm(valuesOperation[0]) if valuesOperation[0] != "path": image_elem.update(valuesOperation[0])
def get_poop_description(previous=None): colours = ['πράσινα', 'καφέ', 'κίτρινα', 'μαύρα'] consistencies = ['υγρά', 'στέρεα', 'σποράκια', 'βλέννα', 'αίμα'] attributes = colours + consistencies if previous is None: default_attr = {k: False for k in attributes} else: default_attr = {k: k in previous for k in attributes} win = sg.Window( 'Κακά', layout=( [[sg.CBox(k, default=v, key=k)] for k, v in default_attr.items()] + [[sg.Text('Άλλο:'), sg.Input(key='comment_text')], [sg.Button('OK', key='ok'), sg.Button('Άκυρο', key='cancel')]])) event, values = win.Read() if event == 'ok': desc = values.pop('comment_text', '') if len(desc) > 0: output_list = [desc] + [k for k, v in values.items() if v] else: output_list = [k for k, v in values.items() if v] output_str = ', '.join(output_list) else: output_str = None win.Close() return output_str
def searchRouteByLocationWindow(location): layoutOperation = [[sg.Text('What place do you want to explore ?')], [sg.InputText(location)], [], [sg.Text('By what do you want to travel ?')], [ sg.Checkbox('Personal car'), sg.Checkbox('On foot', default=True), sg.Checkbox("Public transportation") ], [sg.Text('What are your interests ?')], [ sg.Checkbox('Arts'), sg.Checkbox('Arhitectural'), sg.Checkbox("Entertainment") ], [sg.Button('Search for me'), sg.Button('Cancel')]] windowOperation = sg.Window('Text it out').Layout(layoutOperation) while True: eventOperation, valuesOperation = windowOperation.Read() if eventOperation in (None, 'Cancel'): windowOperation.close() main() break elif eventOperation in ('Search for me'): windowOperation.close() print(valuesOperation) searchRouteByLocationAlgorithm(valuesOperation[0], valuesOperation)
def __init__(self): self.theme = sg.theme('DarkAmber') self.layout = [[sg.Text('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("Starts With", group_id='choice', key="STARTSWITH"), sg.Radio("Ends With", group_id='choice', key="ENDSWITH")], [sg.Text('Root Path', size=(10,1)), sg.Input('C:/', size=(45,1), key="PATH"), sg.FolderBrowse('Browse', size=(10,1)), sg.Button('Re-Index', size=(10,1), key="_INDEX_"), sg.Button('Search', size=(10,1), bind_return_key=True, key="_SEARCH_")], [sg.Output(size=(50,100))]] self.window = sg.Window('File Search Engine').Layout(self.layout)
def searchByTextResultWindow(locations): layout = [[sg.Text('We found some great places for you..')], [sg.Listbox(values=locations, size=(30, 3))], [sg.Button("Find visiting route"), sg.Button('Cancel')]] windowTextResults = sg.Window('HOLIday').Layout(layout) while True: event, values = windowTextResults.Read() if event in (None, 'Cancel'): windowTextResults.close() main() print("Goodbye") break elif event in ("Find visiting route"): windowTextResults.close() searchRouteByLocationWindow(values[0])
def openWindowTextSearch(): print('Text search') layoutOperation = [[sg.Text('A few words to guide us..')], [sg.InputText('Couple of words')], [sg.Button('Search for me'), sg.Button('Cancel')]] windowOperation = sg.Window('Text it out').Layout(layoutOperation) while True: eventOperation, valuesOperation = windowOperation.Read() if eventOperation in (None, 'Cancel'): windowOperation.close() main() break else: windowOperation.close() searchByTextAlgorithm(valuesOperation[0])
def openWindowRoutesSearch(): print('Route search') layoutOperation = [[sg.Text('What place do you want to explore ?')], [sg.InputText('location')], [sg.Button('HERE !'), sg.Button('Cancel')]] windowOperation = sg.Window('Where ?').Layout(layoutOperation) while True: eventOperation, valuesOperation = windowOperation.Read() if eventOperation in (None, 'Cancel'): windowOperation.close() main() break else: windowOperation.close() searchRouteByLocationWindow(valuesOperation[0])
def searchByLocationRouteResult(param): layout = [[sg.Text('We found an amazing route for you..')], [sg.Listbox(values=param, size=(30, 3))], [sg.Button("Show me on map"), sg.Button('Cancel')]] windowTextResults = sg.Window('HOLIday').Layout(layout) while True: event, values = windowTextResults.Read() if event in (None, 'Cancel'): windowTextResults.close() main() print("Goodbye") break elif event in ("Show me on map"): windowTextResults.close() showMeTheMap(param)
def __manage(self): date_list = sg.popup_get_date() find_date = date(date_list[2], date_list[0], date_list[1]) if not (find_date in self.undone_tasks_): sg.popup("No tasks at this date!") return current_tasks = self.undone_tasks_[find_date] is_open = False while True: if len(current_tasks) == 0: del self.undone_tasks_[find_date] sg.popup("No tasks left for today!") if is_open: window.close() return layout = [[sg.Text("Tasks for " + str(find_date))]] i = 0 for task in current_tasks: i += 1 temp = [ sg.Text(str(i) + ")"), sg.Text(task.title_, font=tkinter.font.ITALIC), sg.Text("Is frog? ") ] if task.is_frog_: temp.append(sg.Text("Yes", text_color='#00FF00')) else: temp.append(sg.Text("No", text_color='#FF0000')) temp.append(sg.Button("Delete", key=i)) layout.append(temp) layout.append([sg.Button("Return")]) window = sg.Window("Manage", layout) is_open = True event, value = window.read() if event == "Return" or sg.WIN_CLOSED: window.close() return print(event) if 1 <= event <= len(current_tasks): self.undone_tasks_[find_date].pop(event - 1) sg.popup("Task was successfully deleted.") window.close() is_open = False continue
def run(self): layout = [[sg.Text("Choose what to do:")], [sg.Button("Add task")], [sg.Button("Current tasks")], [sg.Button("Manage tasks")]] menu_window = sg.Window("To-Do app", layout, resizable=True) while True: event, values = menu_window.read() if event == sg.WIN_CLOSED: break if event == "Add task": menu_window.hide() self.__add_task() if event == "Current tasks": menu_window.hide() self.__current() if event == "Manage tasks": menu_window.hide() self.__manage() menu_window.UnHide() menu_window.close()
def __init__(self): # initialize controller parameters (in dict) self.params = self.initialize_params() # FIWARE parameters self.cb_url = os.getenv("CB_URL", "http://localhost:1026") self.entity_id = None # will be read on the web GUI self.entity_type = "PID_Controller" self.service = os.getenv("FIWARE_SERVICE", '') self.service_path = os.getenv("FIWARE_SERVICE_PATH", '') # Create the fiware header fiware_header = FiwareHeader(service=self.service, service_path=self.service_path) # Create orion context broker client self.ORION_CB = ContextBrokerClient(url=self.cb_url, fiware_header=fiware_header) # initial pid controller list self.controller_list = [] try: self.refresh_list() except: pass # initialize gui window sg.theme("DarkBlue") pid_id_bar = [[ sg.Text("Controller ID", size=(10, 1)), sg.Combo(self.controller_list, key="controller_list"), sg.Button("Refresh") ]] param_bars = [[ sg.Text(param.capitalize(), size=(10, 1)), sg.InputText(self.params[param], key=param) ] for param in self.params.keys()] io_bars = [[sg.Button("Send"), sg.Button("Read")]] layout = pid_id_bar + param_bars + io_bars self.window = sg.Window("PID controller", layout, web_port=80, web_start_browser=True)
def __add_task(self): layout1 = [[sg.Text("Write the task title:")], [sg.InputText()], [sg.Button("Next")]] window1 = sg.Window("To-Do app", layout1, resizable=True) while True: event, values = window1.read() if event == sg.WIN_CLOSED: return if event == "Next": break new_task = Task() new_task.title_ = values[0] window1.close() date_list = sg.popup_get_date() new_task.date_ = date(date_list[2], date_list[0], date_list[1]) str1 = "Is it a frog?" # + emoji.emojize(':frog:') layout2 = [[sg.Text(str1)], [ sg.Text("About 'Eat the frog' method.", text_color='#0645AD', enable_events=True, key='-LINK-') ], [sg.Button("Yes")], [sg.Button("No")]] window2 = sg.Window("To-Do app", layout2, resizable=True) while True: event, values = window2.read() if event == sg.WIN_CLOSED: return if event == '-LINK-': webbrowser.open( r'https://todoist.com/productivity-methods/eat-the-frog') if event == "Yes": new_task.is_frog_ = True break if event == "No": new_task.is_frog_ = False break window2.close() if not (new_task.date_ in self.undone_tasks_): self.undone_tasks_[new_task.date_] = [] self.undone_tasks_[new_task.date_].append(new_task)
def detailed_view(window): layout2 = [ [ sg.Button(event, button_color=('white', color_map[event]), key=event, tooltip=color_map[color]), sg.Button(event, button_color=('black', color_map[event]), key=event + '1', tooltip=color_map[color]) ], [ sg.Text( 'Hover over button to see color value. Click to clocse and return to main interface.' ) ], ] sg.Window('Buttons with white and black text', layout2, keep_on_top=True).Read() window.close() return
def main(): layout = [[sg.Text('Matplotlib Simple Plot', font='Any 20')], [sg.Image(key='-IMAGE-')], [sg.Button('Exit')]] window = sg.Window('Matplotlib Example', layout, finalize=True) fig = plt.figure() x = np.arange(0, 5, 0.1) y = np.sin(x) plt.plot(x, y) draw_figure(fig, window['-IMAGE-']) window.read(close=True)
def create_settings_window(settings): sg.theme(settings['theme']) def TextLabel(text): return sg.Text(text + ':', justification='r', size=(15, 1)) layout = [[sg.Text('Settings', font='Any 15')], [ TextLabel('Theme'), sg.Combo(sg.theme_list(), size=(20, 20), key='-THEME-') ], [sg.Button('Save'), sg.Button('Exit')]] window = sg.Window('Settings', layout, keep_on_top=True, finalize=True) for key in SETTINGS_KEYS_TO_ELEMENT_KEYS: # update window with the values read from settings file try: window[SETTINGS_KEYS_TO_ELEMENT_KEYS[key]].update( value=settings[key]) except Exception as e: print( f'Problem updating PySimpleGUI window from settings. Key = {key}' ) return window
def gui_attributes(): optionRace = ["American Indian", "Asian", "Black", "Hispanic", "White"] optionGender = ["Male", "Female", "Other"] # Options inside gui layout = [ [psg.Text("Race"), psg.Combo(optionRace)], [psg.Text("Gender"), psg.Combo(optionGender)], [psg.Text("History knowledge: "), psg.Slider(range=(0, 100), orientation='h', resolution=5, key="HistorySlider", enable_events=True), psg.Text('', key='historyValue')], [psg.Text("Film knowledge: "), psg.Slider(range=(0, 100), orientation='h', resolution=5, key="FilmSlider", enable_events=True), psg.Text('', key='filmValue')], [psg.Text("Sport knowledge: "), psg.Slider(range=(0, 100), orientation='h', resolution=5, key="SportsSlider", enable_events=True), psg.Text('', key='sportsValue')], [psg.Text('Progress: ', key='progressValue')], [psg.Button("Done")] ] window = psg.Window("Attribute Questions", layout) inputs = [] add = 0 event, values = window.read() values['HistorySlider'] = 0 values['FilmSlider'] = 0 values['SportsSlider'] = 0 while True: event, values = window.read() window['historyValue'].Update(value=values['HistorySlider']) window['filmValue'].Update(value=values['FilmSlider']) window['sportsValue'].Update(value=values['SportsSlider']) add = int(values["HistorySlider"]) + int(values["FilmSlider"]) + int(values["SportsSlider"]) window['progressValue'].Update(value=("Total: " + str(add) + "%")) if event in (None, "Done"): # only activates once done or exit is pressed if add == 100: for i in values: inputs.append(values[i]) break window.close() return inputs
def main(): minesInfo = getMineMap() mainLayout = [[ sg.Button('?', size=(4, 2), key=(i, j), pad=(0, 0)) for j in range(MAX_COLS) ] for i in range(MAX_ROWS)] window = sg.Window('扫雷', mainLayout) while True: event, values = window.read() if event in (sg.WIN_CLOSED, 'Exit'): break # window[(row, col)].update('New text') # To change a button's text, use this pattern # For this example, change the text of the button to the board's value and turn color black window[event].update(minesInfo[event[0]][event[1]], button_color=('Green', 'black')) #最后从屏幕上移除 window.close()
import PySimpleGUIWeb as sg layout = [ [sg.InputText()], [ sg.Button('CE', size=(50, 50)), sg.Button('Backspace', size=(80, 50)), sg.Button('Enter', size=(80, 50)) ], [ sg.Button('7', size=(50, 50)), sg.Button('8', size=(50, 50)), sg.Button('9', size=(50, 50)), sg.Button('/', size=(50, 50)) ], [ sg.Button('4', size=(50, 50)), sg.Button('5', size=(50, 50)), sg.Button('6', size=(50, 50)), sg.Button('*', size=(50, 50)) ], [ sg.Button('1', size=(50, 50)), sg.Button('2', size=(50, 50)), sg.Button('3', size=(50, 50)), sg.Button('-', size=(50, 50)) ], [ sg.Button('+/-', size=(50, 50)), sg.Button('0', size=(50, 50)), sg.Button('.', size=(50, 50)),
ball.gui_circle_figure = graph_elem.draw_circle((x, y), r, fill_color='black', line_color='red') # ------------------- Build and show the GUI Window ------------------- graph_elem = sg.Graph((600, 400), (0, 400), (600, 0), enable_events=True, key='_GRAPH_', background_color='lightblue') layout = [[ sg.Text('Ball Test'), sg.Text('My IP {}'.format(socket.gethostbyname(socket.gethostname()))) ], [graph_elem], [sg.Button('Kick'), sg.Button('Exit')]] window = sg.Window('Window Title', layout, finalize=True) area = Playfield() area.add_balls() # ------------------- GUI Event Loop ------------------- while True: # Event Loop event, values = window.read(timeout=0) # print(event, values) if event in (None, 'Exit'): break area.space.step(0.02) for ball in area.arena_balls: if event == 'Kick':
print(launch.mod.get("Add-Computer")[1]) input_list = [] for x in test[2]: input_list.append(x) launch.layout.append( [Sg.InputText("{}".format(str(x)), key="{}".format(x))]) launch.layout_finals = [ [ Sg.Column([[ Sg.DropDown(launch.dropdown_list, enable_events=True, default_value=v[0]) ], [Sg.Button("Execute", size=(25, 1))]]) ], [Sg.Column(launch.layout_final)], [ Sg.DropDown(launch.mod.get("{}".format(element[0]))[3], key="dd_ex") ], [ Sg.Column(launch.layout), Sg.Column([[ Sg.Text(launch.mod.get("{}".format(element[0]))[1], size=(800, 200), key="{}".format(element[0]), auto_size_text=True) ]]) ], [Sg.Column([[Sg.Multiline("ok", key="ex_out", size=(500, 900))]])]
def main(): ComputeStrLayout = [[ sg.Multiline(key='computeStr', background_color='black', text_color='yellow', font="any 30", size=(60, 4)) ]] numsBtLayout = [[ sg.Button(i * 3 + j, size=(4, 2), button_color=('white', 'green'), key=i * 3 + j) for j in range(1, 4) ] for i in range(0, 3)] comBtLayout1= [[sg.Button('0',size=(4,2),key=0),sg.Button('.',size=(4,2),key='.')],\ [sg.Button('(',size=(4,2),key='('),sg.Button('C',size=(4,2),key='C')],\ [sg.Button(')',size=(4,2),key=')'),sg.Button('<=',size=(4,2),key='BackDel')],\ ] comBtLayout2=[\ [sg.Button('+',size=(4,2),key='+'),\ sg.Button('-',size=(4,2),key='-'),\ sg.Button('×',size=(4,2),key='*'),\ sg.Button('÷',size=(4,2),key='/'),\ sg.Button('=',size=(4,2),key='=')]\ ] mainLayout=[[sg.Frame('',ComputeStrLayout)],\ [sg.Frame('',numsBtLayout),\ sg.Column(comBtLayout1)],\ [sg.Frame('',comBtLayout2)],\ ] window = sg.Window('计算器', mainLayout) while True: event, values = window.read() if event in (sg.WIN_CLOSED, 'Exit'): #最后从屏幕上移除 window.close() break if event in list( range(10)) or event in ['.', '(', ')', '+', '-', '*', '/']: window['computeStr'].update(values['computeStr'] + str(event)) elif event == 'C': window['computeStr'].update('') elif event == '=': window['computeStr'].update("%.2f" % computeResult(values['computeStr'])) elif event == 'BackDel': window['computeStr'].update(values['computeStr'][:-1])
windowOperation.close() main() break else: windowOperation.close() searchRouteByLocationWindow(valuesOperation[0]) sg.ChangeLookAndFeel('Dark') sg.SetOptions(element_padding=(5, 5), button_element_size=(15, 2), auto_size_buttons=False, button_color=('white', 'firebrick4')) layout = [[sg.Text('Let us plan an awesome holiday for you..')], [ sg.Button('Search with text'), sg.Button('Search with image'), sg.Button('Create a route') ], [sg.Button('Cancel')]] window = sg.Window('HOLIday').Layout(layout) def main(): # try: # window.enable() # except(Exception): # print("NOW") while True: event, values = window.Read() if event in (None, 'Cancel'):
# ------------------- Build and show the GUI Window ------------------- graph_elem = sg.Graph((600, 400), (0, 400), (600, 0), enable_events=True, key='_GRAPH_', background_color='lightblue') layout = [ [ sg.Text('Ball Test'), sg.T('My IP {}'.format(socket.gethostbyname(socket.gethostname()))) ], [graph_elem], # [sg.Up(), sg.Down()], [sg.B('Kick'), sg.Button('Exit')] ] window = sg.Window( 'Window Title', layout, ).Finalize() area = Playfield() area.add_balls() # ------------------- GUI Event Loop ------------------- while True: # Event Loop event, values = window.Read(timeout=0) # print(event, values) if event in (None, 'Exit'):
#Credit to aminusfu : https://github.com/cherrypy/cherrypy/blob/0857fa81eb0ab647c7b59a019338bab057f7748b/cherrypy/process/wspbus.py#L305 startup_cwd = os.getcwd() #Used in do_execv, to swap between projects #------------- Context Manager ------------# try: #If started from COMMAND, user can choose his directory directly SELECTED_DIR = sys.argv[1] except IndexError: SELECTED_DIR = '' #If no system argument is provided, provide GUI to choose if SELECTED_DIR == '': prompt_layout = [ [sg.Combo(PROJECTS)], [sg.Button('Open')], [sg.Text(key='-INFO-', size=(20, 1))], ] prompt_window = sg.Window( 'Select your project', prompt_layout, location=(80, 500), ) while True: event, values = prompt_window.Read() if event in (None, 'Exit'): break if event == 'Open': for dir_name_from_combo in values.values():
background_color="#272533", text_color='white', font=('Franklin Gothic Book', 14, 'bold')) ], [ sg.Text('0.0000', size=(18, 3), justification='right', background_color='black', text_color='red', font=('Digital-7', 48), relief='sunken', key="_DISPLAY_") ], [ sg.Button('C', **bt), sg.Button('CE', **bt), sg.Button('%', **bt), sg.Button("/", **bt) ], [ sg.Button('7', **bw), sg.Button('8', **bw), sg.Button('9', **bw), sg.Button("*", **bt) ], [ sg.Button('4', **bw), sg.Button('5', **bw), sg.Button('6', **bw), sg.Button("-", **bt)
sg.Text('', size=(10, 1)), sg.Text('SDSS BAL Factory: Visual Inspection', size=(140, 2), font=('Comic sans ms', 40), text_color='red') ], [ sg.Text('', size=(50, 1)), sg.Image( filename= '/Users/vzm83/SDSSIV_BALQSO/pngtree-creative-simple-dividing-line.png', visible=True) ], [ sg.Text('', size=(30, 1)), sg.Button('Previous Quasar', font=('Comic sans ms', 20)), sg.Text('', size=(5, 1), key='_TEXT_008'), sg.Button('Next Quasar', font=('Comic sans ms', 20)), sg.Text('', size=(25, 1), key='_TEXT_009'), sg.Button('MARK for future', font=('Comic sans ms', 20)), sg.Text('', size=(25, 1)), sg.Button('WRITE to Database', font=('Comic sans ms', 20)), sg.Text('', size=(25, 1)), sg.Button('Reset', font=('Comic sans ms', 20)), sg.Text('', size=(20, 1)), sg.Text('', size=(5, 1)), sg.Button('Exit', font=('Comic sans ms', 20)) ], [sg.Text('', size=(30, 1))], [ sg.Text('', size=(30, 1)),
def __current(self): current_index = 0 is_open = False while True: today = date.today() frogs = [] usual = [] if not (today in self.undone_tasks_): sg.popup( "Hooray! No tasks for today! You can chill and enjoy your life." ) if is_open: window.close() break for i in range(current_index, len(self.undone_tasks_[today])): x = self.undone_tasks_[today][i] if x.is_frog_: frogs.append(x) else: usual.append(x) for i in range(0, current_index): x = self.undone_tasks_[today][i] if x.is_frog_: frogs.append(x) else: usual.append(x) undone_amount = len(frogs) + len(usual) all_amount = undone_amount + (len(self.done_tasks_[today]) if (today in self.done_tasks_) else 0) layout = [[sg.Text("Today is " + str(today))]] if undone_amount == 0: sg.popup("Congratulations! You have done all tasks for today!") if is_open: window.close() break else: layout.append([ sg.Text( f'You have completed {all_amount - undone_amount} from {all_amount} tasks today.' f' Good work!') ]) if len(frogs) > 0: current_task = frogs[len(frogs) - 1] else: current_task = usual[len(usual) - 1] layout.append([sg.Text("Current task:")]) layout.append( [sg.Text(current_task.title_, font=tkinter.font.ITALIC)]) layout.append([sg.Text("Is frog?")]) # print("Is frog?", emoji.emojize(':frog:'), end="") if current_task.is_frog_: layout.append([sg.Text("Yes", text_color='#00FF00')]) else: layout.append([sg.Text("No", text_color='#FF0000')]) layout.append([sg.Button("Done")]) layout.append([sg.Button("Skip")]) layout.append([sg.Button("Return")]) window = sg.Window("Current wokflow", layout, resizable=True) is_open = True event, value = window.read() if event == "Done": if not (today in self.done_tasks_): self.done_tasks_[today] = [] self.done_tasks_[today].append(current_task) self.undone_tasks_[today].remove(current_task) if not self.undone_tasks_[today]: del self.undone_tasks_[today] window.close() is_open = False continue if event == "Skip": if current_task.is_frog_: sg.popup("You can't skip the frog!") window.close() continue current_index += 1 current_index %= len(self.undone_tasks_[today]) is_open = False window.close() continue if event == "Return" or event == sg.WIN_CLOSED: window.close() is_open = False break
sg.Drop(values=intervals, key='INTERVAL_NEW', size=(6, 1), tooltip='select acquisition interval', readonly=True, default_value=intervals[3]), sg.Checkbox('Active', key='ACTIVATE_NEW') ] column0 = [ [sg.Text('New entry', font=("Helvetica", 25))], [ sg.Text( 'Update below fields with desiered configuration to fetch data from PLC' ) ], data_row.copy(), [sg.Button("Add"), sg.Button('Clear')], [sg.Text('Edit actual entries', font=("Helvetica", 25))], [ sg.Text( 'Select PLC IP address to get configured data aliases, then choose one to get all parameters connected with it' ) ] ] plc_list = [] alias_list = [] plc_list = get_actual_plcs() column1 = [[sg.Text('PLC IP address\t\t\tData alias')], [ sg.DropDown(values=tuple(plc_list), size=(15, 1),
sg.ChangeLookAndFeel('GreenTan') layout = [ [sg.Text('PySimpleGUIWeb running on the web and in your browser!', size=(60,1), font=('Comic sans ms', 20), text_color='red')], [sg.Text('This program has been running for... ', size=(30,1)),sg.Text('', size=(30,1), key='_DATE_')], [sg.Text('', size=(30,1), key='_TEXT_')], [sg.Input('Single Line Input', do_not_clear=True, enable_events=True, size=(30,1))], [sg.Multiline('Multiline Input', do_not_clear=True, size=(40,4), enable_events=True)], [sg.Multiline('Multiline Output', size=(80,8), key='_MULTIOUT_', font='Courier 12')], [sg.Checkbox('Checkbox 1', enable_events=True, key='_CB1_'), sg.Checkbox('Checkbox 2', default=True, enable_events=True, key='_CB2_')], [sg.Combo(values=['Combo 1', 'Combo 2', 'Combo 3'], default_value='Combo 2', key='_COMBO_',enable_events=True, readonly=False, tooltip='Combo box', disabled=False, size=(12,1))], [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(10,3))], [sg.Slider((1,100), default_value=80, key='_SLIDER_', visible=True, enable_events=True, orientation='h')], [sg.Spin(values=(1,2,3),initial_value=2, size=(4,1))], [sg.Image(filename=r'dot:logo.jpg')], [sg.OK(), sg.Button('Exit', button_color=('white', 'red'))] ] window = sg.Window('My PySimpleGUIWeb Window', default_element_size=(30,1), font='Helvetica 18', background_image=r'dot:logo.jpg' ).Layout(layout) start_time = datetime.datetime.now() while True: event, values = window.Read(timeout=10) if event != sg.TIMEOUT_KEY: print(event, values) window.Element('_MULTIOUT_').Update(str(event) + '\n' + str(values), append=True) if event in (None, 'Exit'):
| |_) / _ \| '_ \| | | | '_ \ | __/ (_) | |_) | |_| | |_) | |_| \___/| .__/ \__,_| .__/ |_| |_| A Popup demonstration. A "Popup" window is shown over the main window. Clicking OK will close the Popup and you return to main again. """ print('Starting up...') layout = [[ sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_') ], [sg.Input('', key='_IN_')], [sg.Button('Show'), sg.Button('Exit'), sg.Button('Blank')]] window = sg.Window('Window Title', layout) while True: # Event Loop print('in event loop') event, values = window.read() print(event, values) if event in (None, 'Exit'): break if event == 'Show': sg.popup('A popup!', ' You typed ', values['_IN_'])