Show More
@@ -26,6 +26,32 import signal | |||
|
26 | 26 | import sys |
|
27 | 27 | import uuid |
|
28 | 28 | |
|
29 | # If run on Windows, install an exception hook which pops up a | |
|
30 | # message box. Pythonw.exe hides the console, so without this | |
|
31 | # the application silently fails to load. | |
|
32 | # | |
|
33 | # We always install this handler, because the expectation is for | |
|
34 | # qtconsole to bring up a GUI even if called from the console. | |
|
35 | # The old handler is called, so the exception is printed as well. | |
|
36 | # If desired, check for pythonw with an additional condition | |
|
37 | # (sys.executable.lower().find('pythonw.exe') >= 0). | |
|
38 | if os.name == 'nt': | |
|
39 | old_excepthook = sys.excepthook | |
|
40 | ||
|
41 | def gui_excepthook(exctype, value, tb): | |
|
42 | try: | |
|
43 | import ctypes, traceback | |
|
44 | MB_ICONERROR = 0x00000010L | |
|
45 | title = u'Error starting IPython QtConsole' | |
|
46 | msg = u''.join(traceback.format_exception(exctype, value, tb)) | |
|
47 | ctypes.windll.user32.MessageBoxW(0, msg, title, MB_ICONERROR) | |
|
48 | finally: | |
|
49 | # Also call the old exception hook to let it do | |
|
50 | # its thing too. | |
|
51 | old_excepthook(exctype, value, tb) | |
|
52 | ||
|
53 | sys.excepthook = gui_excepthook | |
|
54 | ||
|
29 | 55 | # System library imports |
|
30 | 56 | from IPython.external.qt import QtCore, QtGui |
|
31 | 57 |
General Comments 0
You need to be logged in to leave comments.
Login now