diff --git a/IPython/frontend/qt/console/console_widget.py b/IPython/frontend/qt/console/console_widget.py index 1d32620..79ef1d0 100644 --- a/IPython/frontend/qt/console/console_widget.py +++ b/IPython/frontend/qt/console/console_widget.py @@ -369,8 +369,7 @@ class ConsoleWidget(QtGui.QPlainTextEdit): 'keep_input' is set, restores the old input buffer when the new prompt is written. """ - super(ConsoleWidget, self).clear() - + QtGui.QPlainTextEdit.clear(self) input_buffer = '' if self._reading: self._reading = False diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py index 9e336d2..db1ab48 100644 --- a/IPython/frontend/qt/console/frontend_widget.py +++ b/IPython/frontend/qt/console/frontend_widget.py @@ -1,5 +1,6 @@ # Standard library imports import signal +import sys # System library imports from pygments.lexers import PythonLexer @@ -256,6 +257,13 @@ class FrontendWidget(HistoryConsoleWidget): self._complete_pos = self.textCursor().position() return True + def _get_banner(self): + """ Gets a banner to display at the beginning of a session. + """ + banner = 'Python %s on %s\nType "help", "copyright", "credits" or ' \ + '"license" for more information.' + return banner % (sys.version, sys.platform) + def _get_context(self, cursor=None): """ Gets the context at the current cursor location. """ @@ -280,7 +288,11 @@ class FrontendWidget(HistoryConsoleWidget): def _started_channels(self): """ Called when the kernel manager has started listening. """ - self.clear() + QtGui.QPlainTextEdit.clear(self) + if self._reading: + self._reading = False + self.appendPlainText(self._get_banner()) + self._show_prompt() def _stopped_channels(self): """ Called when the kernel manager has stopped listening. diff --git a/IPython/frontend/qt/console/ipython_widget.py b/IPython/frontend/qt/console/ipython_widget.py index b26b639..ee08223 100644 --- a/IPython/frontend/qt/console/ipython_widget.py +++ b/IPython/frontend/qt/console/ipython_widget.py @@ -2,6 +2,7 @@ from PyQt4 import QtCore, QtGui # Local imports +from IPython.core.usage import default_banner from frontend_widget import FrontendWidget @@ -51,6 +52,15 @@ class IPythonWidget(FrontendWidget): self.execute('run %s' % path, hidden=hidden) #--------------------------------------------------------------------------- + # 'FrontendWidget' protected interface + #--------------------------------------------------------------------------- + + def _get_banner(self): + """ Reimplemented to a return IPython's default banner. + """ + return default_banner + + #--------------------------------------------------------------------------- # 'IPythonWidget' interface #---------------------------------------------------------------------------