##// END OF EJS Templates
inputhook: make PyQt4 plays nicer with pyreadline...
Christian Boos -
Show More
@@ -197,31 +197,31 b' class InputHookManager(object):'
197 """
197 """
198 from IPython.external.qt_for_kernel import QtCore, QtGui
198 from IPython.external.qt_for_kernel import QtCore, QtGui
199
199
200 if 'pyreadline' in sys.modules:
201 # see IPython GitHub Issue #281 for more info on this issue
202 # Similar intermittent behavior has been reported on OSX,
203 # but not consistently reproducible
204 warnings.warn("""PyReadline's inputhook can conflict with Qt, causing delays
205 in interactive input. If you do see this issue, we recommend using another GUI
206 toolkit if you can, or disable readline with the configuration option
207 'TerminalInteractiveShell.readline_use=False', specified in a config file or
208 at the command-line""",
209 RuntimeWarning)
210
211 # PyQt4 has had this since 4.3.1. In version 4.2, PyOS_InputHook
212 # was set when QtCore was imported, but if it ever got removed,
213 # you couldn't reset it. For earlier versions we can
214 # probably implement a ctypes version.
215 try:
216 QtCore.pyqtRestoreInputHook()
217 except AttributeError:
218 pass
219
220 self._current_gui = GUI_QT4
221 if app is None:
200 if app is None:
222 app = QtCore.QCoreApplication.instance()
201 app = QtCore.QCoreApplication.instance()
223 if app is None:
202 if app is None:
224 app = QtGui.QApplication([" "])
203 app = QtGui.QApplication([" "])
204
205 # Always use the following input hook instead of PyQt4's
206 # default one, as it interacts better with readline packages
207 # (issue #481)
208
209 def inputhook_qt4():
210 try:
211 app.processEvents(QtCore.QEventLoop.AllEvents, 300)
212 if not stdin_ready():
213 timer = QtCore.QTimer()
214 timer.timeout.connect(app.quit)
215 while not stdin_ready():
216 timer.start(50)
217 app.exec_()
218 timer.stop()
219 except KeyboardInterrupt:
220 pass
221 return 0
222 self.set_inputhook(inputhook_qt4)
223
224 self._current_gui = GUI_QT4
225 app._in_event_loop = True
225 app._in_event_loop = True
226 self._apps[GUI_QT4] = app
226 self._apps[GUI_QT4] = app
227 return app
227 return app
General Comments 0
You need to be logged in to leave comments. Login now