Merge pull request #6609 from PySimpleGUI/Dev-latest

Make the multiple open demo program more useful
This commit is contained in:
PySimpleGUI 2023-11-23 14:28:46 -05:00 committed by GitHub
commit 634eb9c652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -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__':