All multi-window design patterns updated to use the new read_all_windows() call.

This commit is contained in:
PySimpleGUI 2020-07-30 08:13:54 -04:00
parent 102e61cdab
commit b8289c7360
4 changed files with 133 additions and 97 deletions

View file

@ -12,16 +12,16 @@ import PySimpleGUI as sg
def make_win1():
layout = [[sg.Text('This is the FIRST WINDOW'), sg.Text(' ', k='-OUTPUT-')],
[sg.Text()],
[sg.Text('Click Popup anytime to see a modal popup')],
[sg.Button('Launch 2nd Window'), sg.Button('Popup'), sg.Button('Exit')]]
return sg.Window('Window Title', layout, location=(800,600), finalize=True)
def make_win2():
layout = [[sg.Text('The second window')],
[sg.Input(key='-IN-')],
[sg.Input(key='-IN-', enable_events=True)],
[sg.Text(size=(25,1), k='-OUTPUT-')],
[sg.Button('Show'), sg.Button('Popup'), sg.Button('Exit')]]
[sg.Button('Erase'), sg.Button('Popup'), sg.Button('Exit')]]
return sg.Window('Second Window', layout, finalize=True)
window1, window2 = make_win1(), None # start off with 1 window open
@ -38,6 +38,9 @@ while True: # Event Loop
sg.popup('This is a BLOCKING popup','all windows remain inactive while popup active')
elif event == 'Launch 2nd Window' and not window2:
window2 = make_win2()
elif event == 'Show':
elif event == '-IN-':
window['-OUTPUT-'].update(f'You enetered {values["-IN-"]}')
elif event == 'Erase':
window['-OUTPUT-'].update('')
window['-IN-'].update('')
window.close()