Merge pull request #2760 from PySimpleGUI/Dev-latest

enable_events recipe updated
This commit is contained in:
PySimpleGUI 2020-04-02 10:54:50 -04:00 committed by GitHub
commit 9cd0a12bd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -868,10 +868,10 @@ while True: # the event loop
event, values = window.read()
if event in (None, 'Exit'):
break
if event == 'Ok':
if values['-COLOR-']: # if something is highlighted in the list
sg.popup(f"Your favorite color is {values['-COLOR-'][0]}")
window.close()
```
![image](https://user-images.githubusercontent.com/46163555/78260531-10123300-74cc-11ea-9050-83cbdd0dc978.png)
@ -904,7 +904,6 @@ while True: # the event loop
if values['-COLOR-']: # if something is highlighted in the list
sg.popup(f"Your favorite color is {values['-COLOR-'][0]}")
window.close()
```
![image](https://user-images.githubusercontent.com/46163555/78261430-38e6f800-74cd-11ea-8789-dd82919d20fb.png)
@ -912,7 +911,7 @@ window.close()
You won't need to click the OK button anymore because as soon as you make the selection in the listbox the `read()` call returns and the popup will be displayed as before.
This second example code could be used with the OK button. It doesn't matter what event caused the `window.read()` to return. The important thing is whether or not a valid selection was made. The check for `event == 'Ok'` is actually not needed.
------