2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-10-30 17:07:12 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
layout = [
|
|
|
|
[sg.Text('Your typed chars appear here:'),
|
|
|
|
sg.Text(size=(20, 1), key='-OUTPUT-')],
|
|
|
|
[sg.Input('', key='-IN-')],
|
|
|
|
[sg.Button('Show'), sg.Button('Exit')]
|
|
|
|
]
|
2018-10-30 17:07:12 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window = sg.Window('Window Title', layout)
|
2018-10-30 17:07:12 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
while True:
|
|
|
|
event, values = window.read()
|
2018-10-31 16:19:13 +00:00
|
|
|
print(event, values)
|
2020-05-07 10:22:59 +00:00
|
|
|
if event in (sg.WIN_CLOSED, 'Exit'):
|
2018-10-30 17:07:12 +00:00
|
|
|
break
|
2018-10-30 17:16:14 +00:00
|
|
|
if event == 'Show':
|
2019-10-23 20:10:03 +00:00
|
|
|
# change the "output" element to be the value of "input" element
|
|
|
|
window['-OUTPUT-'].update(values['-IN-'])
|
2018-10-31 16:19:13 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window.close()
|