Skip to content

Commit 05939b2

Browse files
committed
Make the multiple open demo program more useful
1 parent e949083 commit 05939b2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

DemoPrograms/Demo_Window_Open_Multiple_Times.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
1111
The purpose of this demo is to show you the simple "make window" design pattern. It simply makes a
1212
window using a layout that's defined in that function and returns the Window object. It's not a bad
13-
way to encapsulate windows if your applcation is gettinga little larger than the typical small data
13+
way to encapsulate windows if your application is getting a little larger than the typical small data
1414
entry window.
1515
16-
Copyright 2020 PySimpleGUI.org
16+
Copyright 2020, 2023 PySimpleGUI.org
1717
"""
1818

1919

@@ -25,11 +25,12 @@ def make_window():
2525
:return: Window that is created using the layout defined in the function
2626
:rtype: Window
2727
"""
28-
layout = [[sg.Text('My Window')],
29-
[sg.Input(key='-IN-'), sg.Text(size=(12, 1), key='-OUT-')],
30-
[sg.Button('Go'), sg.Button('Exit')]]
28+
layout = [[sg.Text('The program will only exit using the "Quit Program" button.')],
29+
[sg.Text('Closing the window or using Exit button will cause a new window to be created.')],
30+
[sg.Input(key='-IN-')],
31+
[sg.Button('Does Nothing'), sg.Button('Exit'), sg.Button('Quit Program')]]
3132

32-
return sg.Window('Window Title', layout)
33+
return sg.Window('Window that restarts on exit', layout)
3334

3435

3536
def main():
@@ -41,8 +42,10 @@ def main():
4142
if event == sg.WIN_CLOSED or event == 'Exit':
4243
window.close()
4344
window = make_window()
44-
elif event == 'Go':
45-
window['-OUT-'].update(values['-IN-'])
45+
elif event == 'Quit Program': # The Quit Program button break out of event loop and exits program
46+
break
47+
48+
window.close()
4649

4750

4851
if __name__ == '__main__':

0 commit comments

Comments
 (0)