MCPcopy Create free account
hub / github.com/ipython/ipython / inputhook_wx2

Function inputhook_wx2

IPython/lib/inputhookwx.py:79–103  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

77 self.evtloop.Exit()
78
79def 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
105def inputhook_wx3():
106 """Run the wx event loop by processing pending events only.

Callers

nothing calls this directly

Calls 2

RunMethod · 0.95
EventLoopRunnerClass · 0.70

Tested by

no test coverage detected