Run the wx event loop, polling for stdin. This version runs the wx eventloop for an undetermined amount of time, during which it periodically checks to see if anything is ready on stdin. If anything is ready on stdin, the event loop exits. The argument to elr.Run controls how ofte
()
| 77 | self.evtloop.Exit() |
| 78 | |
| 79 | def inputhook_wx2(): |
| 80 | """Run the wx event loop, polling for stdin. |
| 81 | |
| 82 | This version runs the wx eventloop for an undetermined amount of time, |
| 83 | during which it periodically checks to see if anything is ready on |
| 84 | stdin. If anything is ready on stdin, the event loop exits. |
| 85 | |
| 86 | The argument to elr.Run controls how often the event loop looks at stdin. |
| 87 | This determines the responsiveness at the keyboard. A setting of 1000 |
| 88 | enables a user to type at most 1 char per second. I have found that a |
| 89 | setting of 10 gives good keyboard response. We can shorten it further, |
| 90 | but eventually performance would suffer from calling select/kbhit too |
| 91 | often. |
| 92 | """ |
| 93 | try: |
| 94 | app = wx.GetApp() |
| 95 | if app is not None: |
| 96 | assert wx.Thread_IsMain() |
| 97 | elr = EventLoopRunner() |
| 98 | # As this time is made shorter, keyboard response improves, but idle |
| 99 | # CPU load goes up. 10 ms seems like a good compromise. |
| 100 | elr.Run(time=10) # CHANGE time here to control polling interval |
| 101 | except KeyboardInterrupt: |
| 102 | pass |
| 103 | return 0 |
| 104 | |
| 105 | def inputhook_wx3(): |
| 106 | """Run the wx event loop by processing pending events only. |
nothing calls this directly
no test coverage detected