Make the multiple open demo program more useful
This commit is contained in:
parent
e949083fda
commit
05939b2725
|
@ -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
|
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
|
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.
|
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
|
:return: Window that is created using the layout defined in the function
|
||||||
:rtype: Window
|
:rtype: Window
|
||||||
"""
|
"""
|
||||||
layout = [[sg.Text('My Window')],
|
layout = [[sg.Text('The program will only exit using the "Quit Program" button.')],
|
||||||
[sg.Input(key='-IN-'), sg.Text(size=(12, 1), key='-OUT-')],
|
[sg.Text('Closing the window or using Exit button will cause a new window to be created.')],
|
||||||
[sg.Button('Go'), sg.Button('Exit')]]
|
[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():
|
def main():
|
||||||
|
@ -41,8 +42,10 @@ def main():
|
||||||
if event == sg.WIN_CLOSED or event == 'Exit':
|
if event == sg.WIN_CLOSED or event == 'Exit':
|
||||||
window.close()
|
window.close()
|
||||||
window = make_window()
|
window = make_window()
|
||||||
elif event == 'Go':
|
elif event == 'Quit Program': # The Quit Program button break out of event loop and exits program
|
||||||
window['-OUT-'].update(values['-IN-'])
|
break
|
||||||
|
|
||||||
|
window.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue