MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / main

Function main

DemoPrograms/Demo_Desktop_Widget_Drive_Usage.py:82–113  ·  view source on GitHub ↗
(location)

Source from the content-addressed store, hash-verified

80 return window
81
82def main(location):
83 # we rely on a key error to tell us if a drive was added. So.... we don't want pesky popups or other key erros to be shown
84 sg.set_options(suppress_error_popups=True, suppress_raise_key_errors=False, suppress_key_guessing=True)
85
86 sg.theme(THEME)
87 window = create_window(location)
88 update_window(window) # sets the progress bars
89 try:
90 # ---------------- Event Loop ----------------
91 while True:
92 event, values = window.read(timeout=UPDATE_FREQUENCY_MILLISECONDS)
93 if event in (sg.WIN_CLOSED, sg.WIN_CLOSE_ATTEMPTED_EVENT, 'Exit'):
94 if event != sg.WIN_CLOSED:
95 sg.user_settings_set_entry('-location-', window.current_location()) # The line of code to save the position before exiting
96 break
97
98 if event == 'Edit Me':
99 sp = sg.execute_editor(__file__)
100 elif event == 'Version':
101 sg.popup_scrolled(__file__, sg.get_versions(), keep_on_top=True, location=window.current_location())
102
103 if not update_window(window): # update the window.. if not True then something changed and need to make a new window
104 window.close()
105 window = create_window(location)
106 update_window(window)
107
108
109 except Exception as e:
110 sg.Print('ERROR in event loop', e)
111 sg.popup_error_with_traceback('Crashed', e)
112
113 sg.popup('Check the error!')
114
115
116

Calls 6

current_locationMethod · 0.80
PrintMethod · 0.80
create_windowFunction · 0.70
update_windowFunction · 0.70
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected