Run the TK eventloop until the file handler that we got from the inputhook becomes readable.
()
| 52 | root = tkinter._default_root |
| 53 | |
| 54 | def wait_using_filehandler(): |
| 55 | """ |
| 56 | Run the TK eventloop until the file handler that we got from the |
| 57 | inputhook becomes readable. |
| 58 | """ |
| 59 | # Add a handler that sets the stop flag when `prompt-toolkit` has input |
| 60 | # to process. |
| 61 | stop = [False] |
| 62 | def done(*a): |
| 63 | stop[0] = True |
| 64 | |
| 65 | root.createfilehandler(inputhook_context.fileno(), _tkinter.READABLE, done) |
| 66 | |
| 67 | # Run the TK event loop as long as we don't receive input. |
| 68 | while root.dooneevent(_tkinter.ALL_EVENTS): |
| 69 | if stop[0]: |
| 70 | break |
| 71 | |
| 72 | root.deletefilehandler(inputhook_context.fileno()) |
| 73 | |
| 74 | def wait_using_polling(): |
| 75 | """ |