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
DEFAULT_BASE64_ICON = b'R0lGODlhIQAgAPcAAAAAADBpmDBqmTFqmjJrmzJsnDNtnTRrmTZtmzZumzRtnTdunDRunTRunjVvnzdwnzhwnjlxnzVwoDZxoTdyojhzozl0ozh0pDp1pjp2pjp2pzx0oj12pD52pTt3qD54pjt4qDx4qDx5qTx5qj16qj57qz57rD58rT98rkB4pkJ7q0J9rEB9rkF+rkB+r0d9qkZ/rEl7o0h8p0x9pk5/p0l+qUB+sEyBrE2Crk2Er0KAsUKAskSCtEeEtUWEtkaGuEiHuEiHukiIu0qKu0mJvEmKvEqLvk2Nv1GErVGFr1SFrVGHslaHsFCItFSIs1COvlaPvFiJsVyRuWCNsWSPsWe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8UxAXOQiEg3wIXvCBQLUU4mAhh0R4SCLqJOSEBhhqkAEGHIYgUDaGICIiIoossogj6yBUTQ4htNgiCCB4oIJAtJTIyI2MOOLIIxMtQQIJIwQZpAgwCKRNI43o6Igll1ySSTsI7dOECSaUYOWVKwhkiyVMYuJlJpp0IpA6oJRTkBQopHnCmmu2IBA2mmQi5yZ0fgJKPP+0IwoooZwzkDQ2uCCoCywUyoIW/5DDyaKefOLoJ6LU8w87pJgDTzqmDNSMDpzqYMOnn/7yTyiglBqKKKOMUopA7JgCy0DdeMEjUDM71GqrrcH8QwqqqpbiayqToqJKLwN5g45A0/TAw7LL2krGP634aoopp5yiiiqrZLuKK+jg444uBIHhw7g+MMsDFP/k4wq22rririu4xItLLriAUxAQ5ObrwzL/0PPKu7fIK3C8uxz0w8EIIwzMP/cM7HC88hxEzBBCBGGxxT8AwQzDujws7zcJQVMEEUKUbPITAt1D78OSivSFEUXEXATKA+HTscC80CPSQNGEccQRYhjUDzfxcjPPzkgnLVBAADs=' 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:
font=('Comic sans ms', 20), text_color='Orange', size=(30, 1), key='_TEXT__004') ], [ sg.Text('', size=(20, 1)), sg.Listbox(values=('Must get a follow up', 'May be interesting', 'Typical Source'), size=(20, 4), enable_events=True, key='_LIST_'), sg.Text('', size=(10, 1), key='_TEXT_002'), sg.Slider((1, 10), default_value=1, key='_SLIDER_', visible=True, enable_events=True), sg.Multiline('', do_not_clear=True, size=(40, 4), enable_events=True, key='_VAR_COMMENT_'), sg.Multiline('', do_not_clear=True, size=(40, 4), enable_events=True, key='_QUASAR_COMMENT_'), sg.Text( 'http://skyserver.sdss.org/dr15/en/tools/explore/summary.aspx?ra=0.00591&dec=20.01226', size=(30, 1),
Additionally, if the spinner is changed, the text size is changed and so is the slider In other words, the slider and the spinner are essentially connected together """ fontsize = 12 # initial and smallest font size to show layout = [[ sg.Spin([sz for sz in range(6, 172)], size=(6, 1), font=('Helvetica 20'), initial_value=fontsize, change_submits=True, key='spin'), sg.Slider(range=(6, 172), orientation='h', size=(10, 20), change_submits=True, key='slider', font=('Helvetica 20')), sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontsize), key='text') ]] window = sg.Window("Font size selector", layout) while True: # the event loop event, values = window.read() if event is None or event == 'Quit': break if int(values['spin']) != fontsize: fontsize = int(values['spin']) else:
title='Options', title_color='red', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags') ], [ 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, 1)), sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85) ], [sg.InputOptionMenu(('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), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75),
for y in range(-SIZE_Y, SIZE_Y+1, NUMBER_MARKER_FREQUENCY): graph.DrawLine((-3,y), (3,y)) if y != 0: graph.DrawText( str(y), (-10,y), color='blue') # Create the graph that will be put into the window graph = sg.Graph(canvas_size=(400, 400), graph_bottom_left=(-(SIZE_X+5), -(SIZE_Y+5)), graph_top_right=(SIZE_X+5, SIZE_Y+5), background_color='white', key='graph') # Window layout layout = [[sg.Text('Example of Using Math with a Graph', justification='center', size=(50,1), relief=sg.RELIEF_SUNKEN)], [graph], [sg.Text('y = sin(x / x2 * x1)', font='COURIER 18')], [sg.Text('x1'),sg.Slider((0,200), orientation='h', enable_events=True,key='_SLIDER_')], [sg.Text('x2'),sg.Slider((1,200), orientation='h', enable_events=True,key='_SLIDER2_')]] window = sg.Window('Graph of Sine Function', layout) while True: event, values = window.Read() if event is None: break graph.Erase() draw_axis() prev_x = prev_y = None for x in range(-SIZE_X,SIZE_X): y = math.sin(x/int(values['_SLIDER2_']))*int(values['_SLIDER_']) if prev_x is not None: graph.DrawLine((prev_x, prev_y), (x,y), color='red')