Show More
@@ -73,13 +73,21 class BaseFrontendMixin(object): | |||
|
73 | 73 | """ |
|
74 | 74 | |
|
75 | 75 | #--------------------------------------------------------------------------- |
|
76 | # Private interface | |
|
76 | # 'BaseFrontendMixin' protected interface | |
|
77 | 77 | #--------------------------------------------------------------------------- |
|
78 | 78 | |
|
79 | 79 | def _dispatch(self, msg): |
|
80 | """ Call the frontend handler associated with | |
|
80 | """ Calls the frontend handler associated with the message type of the | |
|
81 | given message. | |
|
81 | 82 | """ |
|
82 | 83 | msg_type = msg['msg_type'] |
|
83 | 84 | handler = getattr(self, '_handle_' + msg_type, None) |
|
84 | 85 | if handler: |
|
85 | 86 | handler(msg) |
|
87 | ||
|
88 | def _is_from_this_session(self, msg): | |
|
89 | """ Returns whether a reply from the kernel originated from a request | |
|
90 | from this frontend. | |
|
91 | """ | |
|
92 | session = self._kernel_manager.session.session | |
|
93 | return msg['parent_header']['session'] == session |
@@ -83,7 +83,7 class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): | |||
|
83 | 83 | # FrontendWidget protected variables. |
|
84 | 84 | self._call_tip_widget = CallTipWidget(self._control) |
|
85 | 85 | self._completion_lexer = CompletionLexer(PythonLexer()) |
|
86 |
self._hidden = |
|
|
86 | self._hidden = False | |
|
87 | 87 | self._highlighter = self._highlighter_class(self) |
|
88 | 88 | self._input_splitter = self._input_splitter_class(input_mode='replace') |
|
89 | 89 | self._kernel_manager = None |
@@ -187,7 +187,6 class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): | |||
|
187 | 187 | elif status == 'abort': |
|
188 | 188 | self._process_execute_abort(msg) |
|
189 | 189 | |
|
190 | self._hidden = True | |
|
191 | 190 | self._show_interpreter_prompt_for_reply(msg) |
|
192 | 191 | self.executed.emit(msg) |
|
193 | 192 | |
@@ -218,13 +217,15 class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): | |||
|
218 | 217 | def _handle_pyout(self, msg): |
|
219 | 218 | """ Handle display hook output. |
|
220 | 219 | """ |
|
221 | self._append_plain_text(msg['content']['data'] + '\n') | |
|
220 | if not self._hidden and self._is_from_this_session(msg): | |
|
221 | self._append_plain_text(msg['content']['data'] + '\n') | |
|
222 | 222 | |
|
223 | 223 | def _handle_stream(self, msg): |
|
224 | 224 | """ Handle stdout, stderr, and stdin. |
|
225 | 225 | """ |
|
226 | self._append_plain_text(msg['content']['data']) | |
|
227 | self._control.moveCursor(QtGui.QTextCursor.End) | |
|
226 | if not self._hidden and self._is_from_this_session(msg): | |
|
227 | self._append_plain_text(msg['content']['data']) | |
|
228 | self._control.moveCursor(QtGui.QTextCursor.End) | |
|
228 | 229 | |
|
229 | 230 | def _started_channels(self): |
|
230 | 231 | """ Called when the KernelManager channels have started listening or |
@@ -75,11 +75,13 class IPythonWidget(FrontendWidget): | |||
|
75 | 75 | def _handle_pyout(self, msg): |
|
76 | 76 | """ Reimplemented for IPython-style "display hook". |
|
77 | 77 | """ |
|
78 | content = msg['content'] | |
|
79 | prompt_number = content['prompt_number'] | |
|
80 | self._append_plain_text(content['output_sep']) | |
|
81 | self._append_html(self._make_out_prompt(prompt_number)) | |
|
82 | self._append_plain_text(content['data'] + '\n' + content['output_sep2']) | |
|
78 | if not self._hidden and self._is_from_this_session(msg): | |
|
79 | content = msg['content'] | |
|
80 | prompt_number = content['prompt_number'] | |
|
81 | self._append_plain_text(content['output_sep']) | |
|
82 | self._append_html(self._make_out_prompt(prompt_number)) | |
|
83 | self._append_plain_text(content['data'] + '\n' + | |
|
84 | content['output_sep2']) | |
|
83 | 85 | |
|
84 | 86 | #--------------------------------------------------------------------------- |
|
85 | 87 | # 'FrontendWidget' interface |
@@ -152,8 +152,10 class Kernel(Configurable): | |||
|
152 | 152 | raw_input = lambda prompt='': self._raw_input(prompt, ident, parent) |
|
153 | 153 | __builtin__.raw_input = raw_input |
|
154 | 154 | |
|
155 | # Set the parent message of the display hook. | |
|
155 | # Set the parent message of the display hook and out streams. | |
|
156 | 156 | self.shell.displayhook.set_parent(parent) |
|
157 | sys.stdout.set_parent(parent) | |
|
158 | sys.stderr.set_parent(parent) | |
|
157 | 159 | |
|
158 | 160 | self.shell.runlines(code) |
|
159 | 161 | except: |
@@ -97,8 +97,10 class Kernel(HasTraits): | |||
|
97 | 97 | raw_input = lambda prompt='': self._raw_input(prompt, ident, parent) |
|
98 | 98 | __builtin__.raw_input = raw_input |
|
99 | 99 | |
|
100 | # Configure the display hook. | |
|
100 | # Set the parent message of the display hook and out streams. | |
|
101 | 101 | sys.displayhook.set_parent(parent) |
|
102 | sys.stdout.set_parent(parent) | |
|
103 | sys.stderr.set_parent(parent) | |
|
102 | 104 | |
|
103 | 105 | exec comp_code in self.user_ns, self.user_ns |
|
104 | 106 | except: |
General Comments 0
You need to be logged in to leave comments.
Login now