MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / old_main

Function old_main

DemoPrograms/Demo_Long_Operations.py:130–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128
129# This is your original code... it's all going great.... until the call takes too long
130def old_main():
131 layout = [ [sg.Text('Direct Call Version')],
132 [sg.Text('How many times to run the loop?'), sg.Input(s=(4,1), key='-IN-')],
133 [sg.Text(s=(30,1), k='-STATUS-')],
134 [sg.Button('Go', bind_return_key=True), sg.Button('Exit')] ]
135
136 window = sg.Window('Window Title', layout)
137
138 while True: # Event Loop
139 event, values = window.read()
140 print(event, values)
141 if event == sg.WIN_CLOSED or event == 'Exit':
142 break
143 elif event == 'Go':
144 if values['-IN-'].isnumeric():
145 window['-STATUS-'].update('Calling your function...')
146 window.refresh() # needed to make the message show up immediately20
147
148 return_value = my_long_func(int(values['-IN-']), a=10)
149
150 window['-STATUS-'].update(f'Completed. Returned: {return_value}')
151 else:
152 window['-STATUS-'].update('Try again... how about an int?')
153
154 window.close()
155
156
157

Callers

nothing calls this directly

Calls 5

readMethod · 0.95
refreshMethod · 0.95
closeMethod · 0.95
my_long_funcFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected