Show More
@@ -3,6 +3,7 b' from __future__ import print_function' | |||
|
3 | 3 | # Standard library imports |
|
4 | 4 | from collections import namedtuple |
|
5 | 5 | import sys |
|
6 | import time | |
|
6 | 7 | |
|
7 | 8 | # System library imports |
|
8 | 9 | from pygments.lexers import PythonLexer |
@@ -361,6 +362,19 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
361 | 362 | self._append_plain_text(text) |
|
362 | 363 | self._control.moveCursor(QtGui.QTextCursor.End) |
|
363 | 364 | |
|
365 | def _handle_shutdown_reply(self, msg): | |
|
366 | """ Handle shutdown signal, only if from other console. | |
|
367 | """ | |
|
368 | if not self._hidden and not self._is_from_this_session(msg): | |
|
369 | if not msg['content']['restart']: | |
|
370 | sys.exit(0) | |
|
371 | else: | |
|
372 | # we just got notified of a restart! | |
|
373 | time.sleep(0.25) # wait 1/4 sec to reest | |
|
374 | # lest the request for a new prompt | |
|
375 | # goes to the old kernel | |
|
376 | self.reset() | |
|
377 | ||
|
364 | 378 | def _started_channels(self): |
|
365 | 379 | """ Called when the KernelManager channels have started listening or |
|
366 | 380 | when the frontend is assigned an already listening KernelManager. |
@@ -31,11 +31,12 b' class MainWindow(QtGui.QMainWindow):' | |||
|
31 | 31 | # 'object' interface |
|
32 | 32 | #--------------------------------------------------------------------------- |
|
33 | 33 | |
|
34 | def __init__(self, frontend): | |
|
34 | def __init__(self, frontend, existing=False): | |
|
35 | 35 | """ Create a MainWindow for the specified FrontendWidget. |
|
36 | 36 | """ |
|
37 | 37 | super(MainWindow, self).__init__() |
|
38 | 38 | self._frontend = frontend |
|
39 | self._existing = existing | |
|
39 | 40 | self._frontend.exit_requested.connect(self.close) |
|
40 | 41 | self.setCentralWidget(frontend) |
|
41 | 42 | |
@@ -50,15 +51,19 b' class MainWindow(QtGui.QMainWindow):' | |||
|
50 | 51 | if kernel_manager and kernel_manager.channels_running: |
|
51 | 52 | title = self.window().windowTitle() |
|
52 | 53 | reply = QtGui.QMessageBox.question(self, title, |
|
53 |
|
|
|
54 | "Closing console. Shutdown kernel as well?\n"+ | |
|
55 | "'Yes' will close the kernel and all connected consoles.", | |
|
54 | 56 | QtGui.QMessageBox.Yes, QtGui.QMessageBox.No, QtGui.QMessageBox.Cancel) |
|
55 | 57 | if reply == QtGui.QMessageBox.Yes: |
|
56 | self.destroy() | |
|
57 | event.ignore() | |
|
58 | elif reply == QtGui.QMessageBox.No: | |
|
59 | 58 | kernel_manager.shutdown_kernel() |
|
60 | 59 | #kernel_manager.stop_channels() |
|
61 | 60 | event.accept() |
|
61 | elif reply == QtGui.QMessageBox.No: | |
|
62 | if self._existing: | |
|
63 | event.accept() | |
|
64 | else: | |
|
65 | self.destroy() | |
|
66 | event.ignore() | |
|
62 | 67 | else: |
|
63 | 68 | event.ignore() |
|
64 | 69 | |
@@ -136,7 +141,7 b' def main():' | |||
|
136 | 141 | widget.kernel_manager = kernel_manager |
|
137 | 142 | |
|
138 | 143 | # Create the main window. |
|
139 | window = MainWindow(widget) | |
|
144 | window = MainWindow(widget, args.existing) | |
|
140 | 145 | window.setWindowTitle('Python' if args.pure else 'IPython') |
|
141 | 146 | window.show() |
|
142 | 147 |
@@ -105,6 +105,9 b' class QtSubSocketChannel(SocketChannelQObject, SubSocketChannel):' | |||
|
105 | 105 | # last-resort sys.excepthook. |
|
106 | 106 | crash_received = QtCore.pyqtSignal(object) |
|
107 | 107 | |
|
108 | # Emitted when a shutdown is noticed. | |
|
109 | shutdown_reply_received = QtCore.pyqtSignal(object) | |
|
110 | ||
|
108 | 111 | #--------------------------------------------------------------------------- |
|
109 | 112 | # 'SubSocketChannel' interface |
|
110 | 113 | #--------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now