IPython GUI event loop exception hook

2019-07-19 15:26发布

Is it possible to get notification of exceptions that accure during IPythons internal GUI-Event-Loop? Here is an example where an exception is raised but not displayed to the user.

minimal.py:

from PyQt4 import QtCore, QtGui
class TestDialog(QtGui.QDialog):
    def __init__(self):
        QtGui.QDialog.__init__(self)

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.timeout)
        self.timer.start(1000)
        self.show()
    def timeout(self):
        print "before exception"
        raise Exception("Do you see me?")
        print "after exception"

w = TestDialog()

On IPython console type:

%gui qt
runfile('minimal.py')

Output is:

before exception
before exception
.
.
.

My system configuration:

win-64
Python 2.7
IPython 2.1.0

标签: pyqt ipython
0条回答
登录 后发表回答