IPython GUI event loop exception hook

浪尽此生 提交于 2019-12-24 05:12:03

问题


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

来源:https://stackoverflow.com/questions/26426419/ipython-gui-event-loop-exception-hook

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!