| 37 | # harness to capture them. |
| 38 | exception = None |
| 39 | def after_callback(): |
| 40 | nonlocal exception |
| 41 | try: |
| 42 | next(test_generator) |
| 43 | except StopIteration: |
| 44 | root.quit() |
| 45 | except Exception as exc: |
| 46 | exception = exc |
| 47 | root.quit() |
| 48 | else: |
| 49 | # Schedule the Tk mainloop to call this function again, |
| 50 | # using a robust method of ensuring that it gets a |
| 51 | # chance to process queued events before doing so. |
| 52 | # See: https://stackoverflow.com/q/18499082#comment65004099_38817470 |
| 53 | root.after(delay, root.after_idle, after_callback) |
| 54 | root.after(0, root.after_idle, after_callback) |
| 55 | root.mainloop() |
| 56 | |