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

Function inputhook_wx2

IPython/terminal/pt_inputhooks/wx.py:76–98  ·  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

(context)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

RunMethod · 0.95
EventLoopRunnerClass · 0.70

Tested by

no test coverage detected