Windows TK doesn't support 'createfilehandler'. So, run the TK eventloop and poll until input is ready.
()
| 72 | root.deletefilehandler(inputhook_context.fileno()) |
| 73 | |
| 74 | def wait_using_polling(): |
| 75 | """ |
| 76 | Windows TK doesn't support 'createfilehandler'. |
| 77 | So, run the TK eventloop and poll until input is ready. |
| 78 | """ |
| 79 | while not inputhook_context.input_is_ready(): |
| 80 | while root.dooneevent(_tkinter.ALL_EVENTS | _tkinter.DONT_WAIT): |
| 81 | pass |
| 82 | # Sleep to make the CPU idle, but not too long, so that the UI |
| 83 | # stays responsive. |
| 84 | time.sleep(.01) |
| 85 | |
| 86 | if root is not None: |
| 87 | if hasattr(root, 'createfilehandler'): |