()
| 128 | |
| 129 | # This is your original code... it's all going great.... until the call takes too long |
| 130 | def 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 |
nothing calls this directly
no test coverage detected