diff --git a/DemoPrograms/Demo_Window_Open_Multiple_Times.py b/DemoPrograms/Demo_Window_Open_Multiple_Times.py index ffcc6a49..ac4bbca7 100644 --- a/DemoPrograms/Demo_Window_Open_Multiple_Times.py +++ b/DemoPrograms/Demo_Window_Open_Multiple_Times.py @@ -10,10 +10,10 @@ import PySimpleGUI as sg The purpose of this demo is to show you the simple "make window" design pattern. It simply makes a window using a layout that's defined in that function and returns the Window object. It's not a bad - way to encapsulate windows if your applcation is gettinga little larger than the typical small data + way to encapsulate windows if your application is getting a little larger than the typical small data entry window. - Copyright 2020 PySimpleGUI.org + Copyright 2020, 2023 PySimpleGUI.org """ @@ -25,11 +25,12 @@ def make_window(): :return: Window that is created using the layout defined in the function :rtype: Window """ - layout = [[sg.Text('My Window')], - [sg.Input(key='-IN-'), sg.Text(size=(12, 1), key='-OUT-')], - [sg.Button('Go'), sg.Button('Exit')]] + layout = [[sg.Text('The program will only exit using the "Quit Program" button.')], + [sg.Text('Closing the window or using Exit button will cause a new window to be created.')], + [sg.Input(key='-IN-')], + [sg.Button('Does Nothing'), sg.Button('Exit'), sg.Button('Quit Program')]] - return sg.Window('Window Title', layout) + return sg.Window('Window that restarts on exit', layout) def main(): @@ -41,8 +42,10 @@ def main(): if event == sg.WIN_CLOSED or event == 'Exit': window.close() window = make_window() - elif event == 'Go': - window['-OUT-'].update(values['-IN-']) + elif event == 'Quit Program': # The Quit Program button break out of event loop and exits program + break + + window.close() if __name__ == '__main__':