2018-10-30 17:07:12 +00:00
|
|
|
import sys
|
2018-10-31 16:19:13 +00:00
|
|
|
|
2018-10-30 17:07:12 +00:00
|
|
|
if sys.version_info[0] >= 3:
|
|
|
|
import PySimpleGUI as sg
|
|
|
|
else:
|
|
|
|
import PySimpleGUI27 as sg
|
|
|
|
|
2018-10-31 16:19:13 +00:00
|
|
|
layout = [[sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_')],
|
|
|
|
[sg.Input(do_not_clear=True, key='_IN_')],
|
2018-10-30 17:16:14 +00:00
|
|
|
[sg.Button('Show'), sg.Button('Exit')]]
|
2018-10-30 17:07:12 +00:00
|
|
|
|
2018-10-30 17:16:14 +00:00
|
|
|
window = sg.Window('Window Title').Layout(layout)
|
2018-10-30 17:07:12 +00:00
|
|
|
|
2018-10-31 16:19:13 +00:00
|
|
|
while True: # Event Loop
|
2018-10-30 17:07:12 +00:00
|
|
|
event, values = window.Read()
|
2018-10-31 16:19:13 +00:00
|
|
|
print(event, values)
|
2018-10-30 17:07:12 +00:00
|
|
|
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
|
2018-10-30 17:07:12 +00:00
|
|
|
window.FindElement('_OUTPUT_').Update(values['_IN_'])
|
2018-10-31 16:19:13 +00:00
|
|
|
|
|
|
|
window.Close()
|