diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 8c2b0e4..e3f5be0 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2787,7 +2787,7 @@ class InteractiveShell(SingletonConfigurable): def enable_gui(self, gui=None): raise NotImplementedError('Implement enable_gui in a subclass') - def enable_pylab(self, gui=None, import_all=True): + def enable_pylab(self, gui=None, import_all=True, welcome_message=False): """Activate pylab support at runtime. This turns on support for matplotlib, preloads into the interactive @@ -2814,7 +2814,7 @@ class InteractiveShell(SingletonConfigurable): # user_ns_hidden with this information. ns = {} try: - gui = pylab_activate(ns, gui, import_all, self) + gui = pylab_activate(ns, gui, import_all, self, welcome_message=welcome_message) except KeyError: error("Backend %r not supported" % gui) return diff --git a/IPython/core/magics/pylab.py b/IPython/core/magics/pylab.py index f07b717..e642058 100644 --- a/IPython/core/magics/pylab.py +++ b/IPython/core/magics/pylab.py @@ -85,4 +85,4 @@ class PylabMagics(Magics): else: import_all_status = True - self.shell.enable_pylab(parameter_s, import_all=import_all_status) + self.shell.enable_pylab(parameter_s, import_all=import_all_status, welcome_message=True) diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py index b1d0023..798ec1d 100644 --- a/IPython/core/pylabtools.py +++ b/IPython/core/pylabtools.py @@ -319,7 +319,7 @@ def configure_inline_support(shell, backend, user_ns=None): user_ns['getfigs'] = getfigs -def pylab_activate(user_ns, gui=None, import_all=True, shell=None): +def pylab_activate(user_ns, gui=None, import_all=True, shell=None, welcome_message=False): """Activate pylab mode in the user's namespace. Loads and initializes numpy, matplotlib and friends for interactive use. @@ -335,6 +335,10 @@ def pylab_activate(user_ns, gui=None, import_all=True, shell=None): import_all : optional, boolean If true, an 'import *' is done from numpy and pylab. + welcome_message : optional, boolean + If true, print a welcome message about pylab, which includes the backend + being used. + Returns ------- The actual gui used (if not given as input, it was obtained from matplotlib @@ -356,12 +360,11 @@ def pylab_activate(user_ns, gui=None, import_all=True, shell=None): import_pylab(user_ns, import_all) if shell is not None: configure_inline_support(shell, backend, user_ns) - - print """ + if welcome_message: + print """ Welcome to pylab, a matplotlib-based Python environment [backend: %s]. For more information, type 'help(pylab)'.""" % backend - # flush stdout, just to be safe - sys.stdout.flush() - - return gui + # flush stdout, just to be safe + sys.stdout.flush() + return gui diff --git a/IPython/core/shellapp.py b/IPython/core/shellapp.py index 7414e6a..4837d0e 100644 --- a/IPython/core/shellapp.py +++ b/IPython/core/shellapp.py @@ -197,7 +197,7 @@ class InteractiveShellApp(Configurable): gui, backend = pylabtools.find_gui_and_backend(self.pylab) self.log.info("Enabling GUI event loop integration, " "toolkit=%s, pylab=%s" % (gui, self.pylab)) - shell.enable_pylab(gui, import_all=self.pylab_import_all) + shell.enable_pylab(gui, import_all=self.pylab_import_all, welcome_message=True) else: self.log.info("Enabling GUI event loop integration, " "toolkit=%s" % self.gui)