diff --git a/DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py b/DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py index b92ff1a6..848d20f1 100644 --- a/DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py +++ b/DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py @@ -1,45 +1,48 @@ import PySimpleGUI as sg -layout = [[ sg.Text('Window 1'),], - [sg.Input(do_not_clear=True)], - [sg.Text('', key='_OUTPUT_')], - [sg.Button('Next >'), sg.Button('Exit')]] +layout = [[sg.Text('Window 1'), ], + [sg.Input(do_not_clear=True)], + [sg.Text('', key='_OUTPUT_')], + [sg.Button('Next >'), sg.Button('Exit')]] win1 = sg.Window('Window 1').Layout(layout) win3_active = win2_active = False while True: - ev1, vals1 = win1.Read(timeout=100) - if ev1 is None or ev1 == 'Exit': - break - win1.FindElement('_OUTPUT_').Update(vals1[0]) + if not win2_active: + ev1, vals1 = win1.Read() + if ev1 is None or ev1 == 'Exit': + break + win1.FindElement('_OUTPUT_').Update(vals1[0]) - if not win2_active and ev1 == 'Next >': - win2_active = True - win1.Hide() - layout2 = [[sg.Text('Window 2')], - [sg.Button('< Prev'), sg.Button('Next >')]] + if not win2_active and ev1 == 'Next >': + win2_active = True + win1.Hide() + layout2 = [[sg.Text('Window 2')], + [sg.Button('< Prev'), sg.Button('Next >')]] - win2 = sg.Window('Window 2').Layout(layout2) + win2 = sg.Window('Window 2').Layout(layout2) - if win2_active: - ev2, vals2 = win2.Read() - if ev2 in (None, 'Exit', '< Prev'): - win2_active = False - win2.Close() - win1.UnHide() - elif ev2 == 'Next >': - win3_active = True - win2_active = False - win2.Hide() - layout3 = [[sg.Text('Window 3')], - [sg.Button('< Prev'), sg.Button('Exit')]] - win3 = sg.Window('Window 3').Layout(layout3) + if win2_active: + ev2, vals2 = win2.Read() + if ev2 in (None, 'Exit', '< Prev'): + win2_active = False + win2.Close() + win1.UnHide() + elif ev2 == 'Next >': + win3_active = True + win2_active = False + win2.Hide() + layout3 = [[sg.Text('Window 3')], + [sg.Button('< Prev'), sg.Button('Exit')]] + win3 = sg.Window('Window 3').Layout(layout3) - if win3_active: - ev3, vals3 = win3.Read() - if ev3 in (None, 'Exit', '< Prev'): - win3.Close() - win3_active = False - win2_active = True - win2.UnHide() \ No newline at end of file + if win3_active: + ev3, vals3 = win3.Read() + if ev3 == '< Prev': + win3.Close() + win3_active = False + win2_active = True + win2.UnHide() + elif ev3 in (None, 'Exit'): + break