PySimpleGUI/DemoPrograms/Demo_Design_Pattern_Multipl...

55 lines
1.5 KiB
Python
Raw Normal View History

2019-03-31 14:04:33 +00:00
import PySimpleGUI as sg
'''
Example of wizard-like PySimpleGUI windows
'''
2019-03-31 14:25:13 +00:00
layout = [[sg.Text('Window 1'), ],
2019-12-24 23:52:47 +00:00
[sg.Input()],
[sg.Text('',size=(20,1), key='-OUTPUT-')],
2019-03-31 14:25:13 +00:00
[sg.Button('Next >'), sg.Button('Exit')]]
2019-03-31 14:04:33 +00:00
window = sg.Window('Window 1', layout)
2019-03-31 14:04:33 +00:00
window3_active = window2_active = False
2019-03-31 14:04:33 +00:00
while True:
if not window2_active:
event1, values1 = window.read()
if event1 is None or event1 == 'Exit':
2019-03-31 14:25:13 +00:00
break
window['-OUTPUT-'].update(values1[0])
2019-03-31 14:04:33 +00:00
if not window2_active and event1 == 'Next >':
window2_active = True
window.hide()
2019-03-31 14:25:13 +00:00
layout2 = [[sg.Text('Window 2')],
[sg.Button('< Prev'), sg.Button('Next >')]]
2019-03-31 14:04:33 +00:00
window2 = sg.Window('Window 2', layout2)
if window2_active:
event2 = window2.read()[0]
if event2 in (sg.WIN_CLOSED, 'Exit', '< Prev'):
window2_active = False
window2.close()
window.un_hide()
elif event2 == 'Next >':
window3_active = True
window2_active = False
window2.hide()
2019-03-31 14:25:13 +00:00
layout3 = [[sg.Text('Window 3')],
[sg.Button('< Prev'), sg.Button('Exit')]]
window3 = sg.Window('Window 3', layout3)
2019-03-31 14:04:33 +00:00
if window3_active:
ev3, vals3 = window3.read()
2019-03-31 14:25:13 +00:00
if ev3 == '< Prev':
window3.close()
window3_active = False
window2_active = True
window2.un_hide()
elif ev3 in (sg.WIN_CLOSED, 'Exit'):
2019-03-31 14:25:13 +00:00
break
window.close()