Show More
@@ -95,6 +95,9 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
95 | enable_calltips = Bool(True, config=True, |
|
95 | enable_calltips = Bool(True, config=True, | |
96 | help="Whether to draw information calltips on open-parentheses.") |
|
96 | help="Whether to draw information calltips on open-parentheses.") | |
97 |
|
97 | |||
|
98 | clear_on_kernel_restart = Bool(True, config=True, | |||
|
99 | help="Whether to clear the console when the kernel is restarted") | |||
|
100 | ||||
98 | # Emitted when a user visible 'execute_request' has been submitted to the |
|
101 | # Emitted when a user visible 'execute_request' has been submitted to the | |
99 | # kernel from the FrontendWidget. Contains the code to be executed. |
|
102 | # kernel from the FrontendWidget. Contains the code to be executed. | |
100 | executing = QtCore.Signal(object) |
|
103 | executing = QtCore.Signal(object) | |
@@ -505,7 +508,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
505 | time.sleep(0.25) # wait 1/4 sec to reset |
|
508 | time.sleep(0.25) # wait 1/4 sec to reset | |
506 | # lest the request for a new prompt |
|
509 | # lest the request for a new prompt | |
507 | # goes to the old kernel |
|
510 | # goes to the old kernel | |
508 | self.reset() |
|
511 | self.reset_on_restart() | |
509 | else: # remote kernel, prompt on Kernel shutdown/reset |
|
512 | else: # remote kernel, prompt on Kernel shutdown/reset | |
510 | title = self.window().windowTitle() |
|
513 | title = self.window().windowTitle() | |
511 | if not msg['content']['restart']: |
|
514 | if not msg['content']['restart']: | |
@@ -516,6 +519,8 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
516 | if reply == QtGui.QMessageBox.Yes: |
|
519 | if reply == QtGui.QMessageBox.Yes: | |
517 | self.exit_requested.emit(self) |
|
520 | self.exit_requested.emit(self) | |
518 | else: |
|
521 | else: | |
|
522 | # XXX: remove message box in favor of using the | |||
|
523 | # clear_on_kernel_restart setting? | |||
519 | reply = QtGui.QMessageBox.question(self, title, |
|
524 | reply = QtGui.QMessageBox.question(self, title, | |
520 | "Kernel has been reset. Clear the Console?", |
|
525 | "Kernel has been reset. Clear the Console?", | |
521 | QtGui.QMessageBox.Yes,QtGui.QMessageBox.No) |
|
526 | QtGui.QMessageBox.Yes,QtGui.QMessageBox.No) | |
@@ -580,6 +585,22 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
580 | self._append_before_prompt_pos = self._get_cursor().position() |
|
585 | self._append_before_prompt_pos = self._get_cursor().position() | |
581 | self._show_interpreter_prompt() |
|
586 | self._show_interpreter_prompt() | |
582 |
|
587 | |||
|
588 | def reset_on_restart(self): | |||
|
589 | """Resets the widget if ``clear_on_kernel_restart`` is True, otherwise | |||
|
590 | prints a visual indication of the fact that the kernel restarted, but | |||
|
591 | does not clear the traces from previous usage of the kernel before it | |||
|
592 | was restarted. | |||
|
593 | """ | |||
|
594 | if self.clear_on_kernel_restart: | |||
|
595 | self.reset() | |||
|
596 | else: | |||
|
597 | self._append_before_prompt_pos = self._get_cursor().position() | |||
|
598 | self._append_plain_text("# restarting kernel...\n#" + "-"*42) | |||
|
599 | # XXX: Reprinting the full banner may be too much, but once #1680 is | |||
|
600 | # addressed, that will mitigate it. | |||
|
601 | #self._append_plain_text(self.banner) | |||
|
602 | self._show_interpreter_prompt() | |||
|
603 | ||||
583 | def restart_kernel(self, message, now=False): |
|
604 | def restart_kernel(self, message, now=False): | |
584 | """ Attempts to restart the running kernel. |
|
605 | """ Attempts to restart the running kernel. | |
585 | """ |
|
606 | """ | |
@@ -611,7 +632,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
611 | before_prompt=True |
|
632 | before_prompt=True | |
612 | ) |
|
633 | ) | |
613 | else: |
|
634 | else: | |
614 | self.reset() |
|
635 | self.reset_on_restart() | |
615 | else: |
|
636 | else: | |
616 | self.kernel_manager.hb_channel.unpause() |
|
637 | self.kernel_manager.hb_channel.unpause() | |
617 |
|
638 | |||
@@ -693,7 +714,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
693 | self._append_plain_text(traceback) |
|
714 | self._append_plain_text(traceback) | |
694 |
|
715 | |||
695 | def _process_execute_ok(self, msg): |
|
716 | def _process_execute_ok(self, msg): | |
696 | """ Process a reply for a successful execution equest. |
|
717 | """ Process a reply for a successful execution request. | |
697 | """ |
|
718 | """ | |
698 | payload = msg['content']['payload'] |
|
719 | payload = msg['content']['payload'] | |
699 | for item in payload: |
|
720 | for item in payload: |
General Comments 0
You need to be logged in to leave comments.
Login now