Moved update animation call to after check for window closed. Was getting an error because attempt to update animation was happening after window was closed

This commit is contained in:
PySimpleGUI 2023-04-22 10:13:36 -04:00
parent 71c50d40b4
commit fb5fdbdd5c
1 changed files with 5 additions and 4 deletions

View File

@ -11,7 +11,7 @@
Displays the values dictionary entry for each element Displays the values dictionary entry for each element
And more! And more!
Copyright 2021, 2022 PySimpleGUI Copyright 2021, 2022, 2023 PySimpleGUI
""" """
import PySimpleGUI as sg import PySimpleGUI as sg
@ -94,12 +94,11 @@ def make_window(theme):
def main(): def main():
window = make_window(sg.theme()) window = make_window(sg.theme())
# This is an Event Loop # This is an Event Loop
while True: while True:
event, values = window.read(timeout=100) event, values = window.read(timeout=100)
# keep an animation running so show things are happening # keep an animation running so show things are happening
window['-GIF-IMAGE-'].update_animation(sg.DEFAULT_BASE64_LOADING_GIF, time_between_frames=100)
if event not in (sg.TIMEOUT_EVENT, sg.WIN_CLOSED): if event not in (sg.TIMEOUT_EVENT, sg.WIN_CLOSED):
print('============ Event = ', event, ' ==============') print('============ Event = ', event, ' ==============')
print('-------- Values Dictionary (key=value) --------') print('-------- Values Dictionary (key=value) --------')
@ -108,7 +107,9 @@ def main():
if event in (None, 'Exit'): if event in (None, 'Exit'):
print("[LOG] Clicked Exit!") print("[LOG] Clicked Exit!")
break break
elif event == 'About':
window['-GIF-IMAGE-'].update_animation(sg.DEFAULT_BASE64_LOADING_GIF, time_between_frames=100)
if event == 'About':
print("[LOG] Clicked About!") print("[LOG] Clicked About!")
sg.popup('PySimpleGUI Demo All Elements', sg.popup('PySimpleGUI Demo All Elements',
'Right click anywhere to see right click menu', 'Right click anywhere to see right click menu',