##// END OF EJS Templates
* The Qt console frontend now ignores cross chatter from other frontends....
epatters -
Show More
@@ -73,13 +73,21 b' class BaseFrontendMixin(object):'
73 """
73 """
74
74
75 #---------------------------------------------------------------------------
75 #---------------------------------------------------------------------------
76 # Private interface
76 # 'BaseFrontendMixin' protected interface
77 #---------------------------------------------------------------------------
77 #---------------------------------------------------------------------------
78
78
79 def _dispatch(self, msg):
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 msg_type = msg['msg_type']
83 msg_type = msg['msg_type']
83 handler = getattr(self, '_handle_' + msg_type, None)
84 handler = getattr(self, '_handle_' + msg_type, None)
84 if handler:
85 if handler:
85 handler(msg)
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 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
83 # FrontendWidget protected variables.
83 # FrontendWidget protected variables.
84 self._call_tip_widget = CallTipWidget(self._control)
84 self._call_tip_widget = CallTipWidget(self._control)
85 self._completion_lexer = CompletionLexer(PythonLexer())
85 self._completion_lexer = CompletionLexer(PythonLexer())
86 self._hidden = True
86 self._hidden = False
87 self._highlighter = self._highlighter_class(self)
87 self._highlighter = self._highlighter_class(self)
88 self._input_splitter = self._input_splitter_class(input_mode='replace')
88 self._input_splitter = self._input_splitter_class(input_mode='replace')
89 self._kernel_manager = None
89 self._kernel_manager = None
@@ -187,7 +187,6 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
187 elif status == 'abort':
187 elif status == 'abort':
188 self._process_execute_abort(msg)
188 self._process_execute_abort(msg)
189
189
190 self._hidden = True
191 self._show_interpreter_prompt_for_reply(msg)
190 self._show_interpreter_prompt_for_reply(msg)
192 self.executed.emit(msg)
191 self.executed.emit(msg)
193
192
@@ -218,11 +217,13 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
218 def _handle_pyout(self, msg):
217 def _handle_pyout(self, msg):
219 """ Handle display hook output.
218 """ Handle display hook output.
220 """
219 """
220 if not self._hidden and self._is_from_this_session(msg):
221 self._append_plain_text(msg['content']['data'] + '\n')
221 self._append_plain_text(msg['content']['data'] + '\n')
222
222
223 def _handle_stream(self, msg):
223 def _handle_stream(self, msg):
224 """ Handle stdout, stderr, and stdin.
224 """ Handle stdout, stderr, and stdin.
225 """
225 """
226 if not self._hidden and self._is_from_this_session(msg):
226 self._append_plain_text(msg['content']['data'])
227 self._append_plain_text(msg['content']['data'])
227 self._control.moveCursor(QtGui.QTextCursor.End)
228 self._control.moveCursor(QtGui.QTextCursor.End)
228
229
@@ -75,11 +75,13 b' class IPythonWidget(FrontendWidget):'
75 def _handle_pyout(self, msg):
75 def _handle_pyout(self, msg):
76 """ Reimplemented for IPython-style "display hook".
76 """ Reimplemented for IPython-style "display hook".
77 """
77 """
78 if not self._hidden and self._is_from_this_session(msg):
78 content = msg['content']
79 content = msg['content']
79 prompt_number = content['prompt_number']
80 prompt_number = content['prompt_number']
80 self._append_plain_text(content['output_sep'])
81 self._append_plain_text(content['output_sep'])
81 self._append_html(self._make_out_prompt(prompt_number))
82 self._append_html(self._make_out_prompt(prompt_number))
82 self._append_plain_text(content['data'] + '\n' + content['output_sep2'])
83 self._append_plain_text(content['data'] + '\n' +
84 content['output_sep2'])
83
85
84 #---------------------------------------------------------------------------
86 #---------------------------------------------------------------------------
85 # 'FrontendWidget' interface
87 # 'FrontendWidget' interface
@@ -152,8 +152,10 b' class Kernel(Configurable):'
152 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
152 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
153 __builtin__.raw_input = raw_input
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 self.shell.displayhook.set_parent(parent)
156 self.shell.displayhook.set_parent(parent)
157 sys.stdout.set_parent(parent)
158 sys.stderr.set_parent(parent)
157
159
158 self.shell.runlines(code)
160 self.shell.runlines(code)
159 except:
161 except:
@@ -97,8 +97,10 b' class Kernel(HasTraits):'
97 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
97 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
98 __builtin__.raw_input = raw_input
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 sys.displayhook.set_parent(parent)
101 sys.displayhook.set_parent(parent)
102 sys.stdout.set_parent(parent)
103 sys.stderr.set_parent(parent)
102
104
103 exec comp_code in self.user_ns, self.user_ns
105 exec comp_code in self.user_ns, self.user_ns
104 except:
106 except:
General Comments 0
You need to be logged in to leave comments. Login now