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AEAAP8ALAAAAAAhACAAAAj/AP8JHEiwoMGDCA1uoYIF4bhK1vwlPOjlQICLApwVpFTGzBk1siYSrCLgoskFyQZKMsOypRyR/GKYnBkgQbF/s8603KnmWkIaNIMaw6lzZ8tYB2cIWMo0KIJj/7YV9XgGDRo14gpOIUBggNevXpkKGCDsXySradSoZcMmDsFnDxpEKEC3bl2uXCFQ+7emjV83bt7AgTNroJINAq0wWBxBgYHHdgt0+cdnMJw5c+jQqYNnoARkAx04kPEvS4PTqBswuPIPUp06duzcuYMHT55wAjkwEahsQgqBNSQIHy582D9BePTs2dOnjx8/f1gJ9GXhRpTqApFQoDChu3cOAps///9D/g+gQvYGjrlw4cU/fUnYX6hAn34HgZMABQo0iJB/Qoe8UxAXOQiEg3wIXvCBQLUU4mAhh0R4SCLqJOSEBhhqkAEGHIYgUDaGICIiIoossogj6yBUTQ4htNgiCCB4oIJAtJTIyI2MOOLIIxMtQQIJIwQZpAgwCKRNI43o6Igll1ySSTsI7dOECSaUYOWVKwhkiyVMYuJlJpp0IpA6oJRTkBQopHnCmmu2IBA2mmQi5yZ0fgJKPP+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:
        print(event, values)
        window.Element('_MULTIOUT_').Update(str(event) + '\n' + str(values), append=True)
    if event in (None, 'Exit'):
        break
    window.Element('_DATE_').Update(str(datetime.datetime.now()-start_time))

window.Close()




