Skip to content

Commit

Permalink
inputhook_qt4: Mimic C-level qtcore_input_hook().
Browse files Browse the repository at this point in the history
Closes ipython#2080.
  • Loading branch information
bfroehle committed Jul 11, 2012
1 parent bf4aa6d commit 2fc3a0a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions IPython/lib/inputhookqt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# Imports
#-----------------------------------------------------------------------------

import sys

from IPython.core.interactiveshell import InteractiveShell
from IPython.external.qt_for_kernel import QtCore, QtGui
from IPython.lib.inputhook import allow_CTRL_C, ignore_CTRL_C, stdin_ready
Expand Down Expand Up @@ -85,12 +87,20 @@ def inputhook_qt4():
return 0
app.processEvents(QtCore.QEventLoop.AllEvents, 300)
if not stdin_ready():
timer = QtCore.QTimer()
timer.timeout.connect(app.quit)
while not stdin_ready():
timer.start(50)
# See python-qt4/sip/QtCore/qcoreapplication.sip
if sys.platform == 'win32': # Proxy for Q_OS_WIN32 (?)
timer = QtCore.QTimer()
timer.timeout.connect(app.quit)
while not stdin_ready():
timer.start(50)
app.exec_()
timer.stop()
timer.timeout.disconnect(app.quit)
else:
notifier = QtCore.QSocketNotifier(0, QtCore.QSocketNotifier.Read)
notifier.activated[int].connect(app.quit)
app.exec_()
timer.stop()
notifier.activated[int].disconnect(app.quit)
except KeyboardInterrupt:
ignore_CTRL_C()
got_kbdint[0] = True
Expand Down

0 comments on commit 2fc3a0a

Please sign in to comment.