def enable_pyqt_exception_hook():
"""Enable the PyQt exception handling hook for PyQt versions larger than 5.5.
If this is not enabled, exceptions will be handled silently and will not be printed to the user. This
makes it harder to solve the issue.
"""
if QtCore.QT_VERSION >= 0x50501:
old_stdout = sys.stdout
old_stderr = sys.stderr
def excepthook(type_, value, traceback_):
sys.stdout = old_stdout
sys.stderr = old_stderr
traceback.print_exception(type_, value, traceback_)
QtCore.qFatal('')
sys.excepthook = excepthook
评论列表
文章目录