PySimpleGUI/DemoPrograms/Demo_Design_Pattern_Persist...

26 lines
696 B
Python
Raw Normal View History

import sys
2018-10-31 16:19:13 +00:00
if sys.version_info[0] >= 3:
import PySimpleGUI as sg
else:
import PySimpleGUI27 as sg
2018-10-31 21:22:26 +00:00
layout = [
[sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_')],
[sg.Input(do_not_clear=True, key='_IN_')],
[sg.Button('Show'), sg.Button('Exit')]
]
2018-10-30 17:16:14 +00:00
window = sg.Window('Window Title').Layout(layout)
2018-10-31 16:19:13 +00:00
while True: # Event Loop
event, values = window.Read()
2018-10-31 16:19:13 +00:00
print(event, values)
if event is None or event == 'Exit':
break
2018-10-30 17:16:14 +00:00
if event == 'Show':
2018-10-31 16:19:13 +00:00
# change the "output" element to be the value of "input" element
window.FindElement('_OUTPUT_').Update(values['_IN_'])
2018-10-31 16:19:13 +00:00
window.Close()