Added do_not_clear parameter
This commit is contained in:
parent
f5f8f0e807
commit
f1a063ad76
|
@ -1,23 +1,23 @@
|
||||||
# -------------------------------------#
|
|
||||||
# DESIGN PATTERN 2 - Persistent Window #
|
|
||||||
# Update a text field based on input #
|
|
||||||
# -------------------------------------#
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
else:
|
else:
|
||||||
import PySimpleGUI27 as sg
|
import PySimpleGUI27 as sg
|
||||||
|
|
||||||
layout = [[sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_') ],
|
layout = [[sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_')],
|
||||||
[sg.Input(key='_IN_')],
|
[sg.Input(do_not_clear=True, key='_IN_')],
|
||||||
[sg.Button('Show'), sg.Button('Exit')]]
|
[sg.Button('Show'), sg.Button('Exit')]]
|
||||||
|
|
||||||
window = sg.Window('Window Title').Layout(layout)
|
window = sg.Window('Window Title').Layout(layout)
|
||||||
|
|
||||||
while True: # Event Loop
|
while True: # Event Loop
|
||||||
event, values = window.Read()
|
event, values = window.Read()
|
||||||
|
print(event, values)
|
||||||
if event is None or event == 'Exit':
|
if event is None or event == 'Exit':
|
||||||
break
|
break
|
||||||
if event == 'Show':
|
if event == 'Show':
|
||||||
# change the "output" element to be the value of "input" element
|
# change the "output" element to be the value of "input" element
|
||||||
window.FindElement('_OUTPUT_').Update(values['_IN_'])
|
window.FindElement('_OUTPUT_').Update(values['_IN_'])
|
||||||
|
|
||||||
|
window.Close()
|
||||||
|
|
Loading…
Reference in New Issue