New Demos - Multiple windows design patterns
This commit is contained in:
parent
48265d438c
commit
9b26e63f44
3 changed files with 128 additions and 0 deletions
35
DemoPrograms/Demo_Design_Pattern_Multiple_Windows1.py
Normal file
35
DemoPrograms/Demo_Design_Pattern_Multiple_Windows1.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
"""
|
||||
PySimpleGUI The Complete Course
|
||||
Lesson 7 - Multiple Windows
|
||||
"""
|
||||
import PySimpleGUI as sg
|
||||
|
||||
# Design pattern 1 - First window does not remain active
|
||||
|
||||
layout = [[ sg.Text('Window 1'),],
|
||||
[sg.Input(do_not_clear=True)],
|
||||
[sg.Text('', key='_OUTPUT_')],
|
||||
[sg.Button('Launch 2')]]
|
||||
|
||||
win1 = sg.Window('Window 1').Layout(layout)
|
||||
win2_active=False
|
||||
while True:
|
||||
ev1, vals1 = win1.Read(timeout=100)
|
||||
if ev1 is None:
|
||||
break
|
||||
win1.FindElement('_OUTPUT_').Update(vals1[0])
|
||||
|
||||
if ev1 == 'Launch 2' and not win2_active:
|
||||
win2_active = True
|
||||
win1.Hide()
|
||||
layout2 = [[sg.Text('Window 2')],
|
||||
[sg.Button('Exit')]]
|
||||
|
||||
win2 = sg.Window('Window 2').Layout(layout2)
|
||||
while True:
|
||||
ev2, vals2 = win2.Read()
|
||||
if ev2 is None or ev2 == 'Exit':
|
||||
win2.Close()
|
||||
win2_active = False
|
||||
win1.UnHide()
|
||||
break
|
Loading…
Add table
Add a link
Reference in a new issue