From 41d5b26cd1561916549db3d887ae4feceab7dd2e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 31 Mar 2019 10:04:33 -0400 Subject: [PATCH] A Next/Previoius design patttern --- .../Demo_Design_Pattern_Multiple_Windows3.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py diff --git a/DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py b/DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py new file mode 100644 index 00000000..b92ff1a6 --- /dev/null +++ b/DemoPrograms/Demo_Design_Pattern_Multiple_Windows3.py @@ -0,0 +1,45 @@ +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')]] + +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 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) + + 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