Merge pull request #1273 from PySimpleGUI/Dev-latest

Made Window 1 a blocking Read
This commit is contained in:
MikeTheWatchGuy 2019-03-31 10:25:38 -04:00 committed by GitHub
commit bfc616e080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 34 deletions

View File

@ -1,45 +1,48 @@
import PySimpleGUI as sg import PySimpleGUI as sg
layout = [[ sg.Text('Window 1'),], layout = [[sg.Text('Window 1'), ],
[sg.Input(do_not_clear=True)], [sg.Input(do_not_clear=True)],
[sg.Text('', key='_OUTPUT_')], [sg.Text('', key='_OUTPUT_')],
[sg.Button('Next >'), sg.Button('Exit')]] [sg.Button('Next >'), sg.Button('Exit')]]
win1 = sg.Window('Window 1').Layout(layout) win1 = sg.Window('Window 1').Layout(layout)
win3_active = win2_active = False win3_active = win2_active = False
while True: while True:
ev1, vals1 = win1.Read(timeout=100) if not win2_active:
if ev1 is None or ev1 == 'Exit': ev1, vals1 = win1.Read()
break if ev1 is None or ev1 == 'Exit':
win1.FindElement('_OUTPUT_').Update(vals1[0]) break
win1.FindElement('_OUTPUT_').Update(vals1[0])
if not win2_active and ev1 == 'Next >': if not win2_active and ev1 == 'Next >':
win2_active = True win2_active = True
win1.Hide() win1.Hide()
layout2 = [[sg.Text('Window 2')], layout2 = [[sg.Text('Window 2')],
[sg.Button('< Prev'), sg.Button('Next >')]] [sg.Button('< Prev'), sg.Button('Next >')]]
win2 = sg.Window('Window 2').Layout(layout2) win2 = sg.Window('Window 2').Layout(layout2)
if win2_active: if win2_active:
ev2, vals2 = win2.Read() ev2, vals2 = win2.Read()
if ev2 in (None, 'Exit', '< Prev'): if ev2 in (None, 'Exit', '< Prev'):
win2_active = False win2_active = False
win2.Close() win2.Close()
win1.UnHide() win1.UnHide()
elif ev2 == 'Next >': elif ev2 == 'Next >':
win3_active = True win3_active = True
win2_active = False win2_active = False
win2.Hide() win2.Hide()
layout3 = [[sg.Text('Window 3')], layout3 = [[sg.Text('Window 3')],
[sg.Button('< Prev'), sg.Button('Exit')]] [sg.Button('< Prev'), sg.Button('Exit')]]
win3 = sg.Window('Window 3').Layout(layout3) win3 = sg.Window('Window 3').Layout(layout3)
if win3_active: if win3_active:
ev3, vals3 = win3.Read() ev3, vals3 = win3.Read()
if ev3 in (None, 'Exit', '< Prev'): if ev3 == '< Prev':
win3.Close() win3.Close()
win3_active = False win3_active = False
win2_active = True win2_active = True
win2.UnHide() win2.UnHide()
elif ev3 in (None, 'Exit'):
break