Merge pull request #4115 from PySimpleGUI/Dev-latest

Updated to use WIN_CLOSED constant
This commit is contained in:
PySimpleGUI 2021-03-26 20:19:47 -04:00 committed by GitHub
commit aebee259c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -9,7 +9,7 @@ import PySimpleGUI as sg
This line binds the F10 keybaord key to the window. It produces a "Go" event:
window.bind('<F10>', 'Go')
Copyright 2021 PySimpleGUI
"""
@ -20,12 +20,11 @@ layout = [ [sg.Text('Press F10 to get same result as clicking "Go" button')],
window = sg.Window('Window Title', layout, finalize=True)
window.bind('<F10>', 'Go')
window.bind('<F10>', 'Go') # Make sure your window is finalized first
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
if event in (sg.WIN_CLOSED, 'Exit'):
break
window.close()