##// END OF EJS Templates
Add welcome_message option to enable_pylab...
Aaron Meurer -
Show More
@@ -2787,7 +2787,7 b' class InteractiveShell(SingletonConfigurable):'
2787 2787 def enable_gui(self, gui=None):
2788 2788 raise NotImplementedError('Implement enable_gui in a subclass')
2789 2789
2790 def enable_pylab(self, gui=None, import_all=True):
2790 def enable_pylab(self, gui=None, import_all=True, welcome_message=False):
2791 2791 """Activate pylab support at runtime.
2792 2792
2793 2793 This turns on support for matplotlib, preloads into the interactive
@@ -2814,7 +2814,7 b' class InteractiveShell(SingletonConfigurable):'
2814 2814 # user_ns_hidden with this information.
2815 2815 ns = {}
2816 2816 try:
2817 gui = pylab_activate(ns, gui, import_all, self)
2817 gui = pylab_activate(ns, gui, import_all, self, welcome_message=welcome_message)
2818 2818 except KeyError:
2819 2819 error("Backend %r not supported" % gui)
2820 2820 return
@@ -85,4 +85,4 b' class PylabMagics(Magics):'
85 85 else:
86 86 import_all_status = True
87 87
88 self.shell.enable_pylab(parameter_s, import_all=import_all_status)
88 self.shell.enable_pylab(parameter_s, import_all=import_all_status, welcome_message=True)
@@ -319,7 +319,7 b' def configure_inline_support(shell, backend, user_ns=None):'
319 319 user_ns['getfigs'] = getfigs
320 320
321 321
322 def pylab_activate(user_ns, gui=None, import_all=True, shell=None):
322 def pylab_activate(user_ns, gui=None, import_all=True, shell=None, welcome_message=False):
323 323 """Activate pylab mode in the user's namespace.
324 324
325 325 Loads and initializes numpy, matplotlib and friends for interactive use.
@@ -335,6 +335,10 b' def pylab_activate(user_ns, gui=None, import_all=True, shell=None):'
335 335 import_all : optional, boolean
336 336 If true, an 'import *' is done from numpy and pylab.
337 337
338 welcome_message : optional, boolean
339 If true, print a welcome message about pylab, which includes the backend
340 being used.
341
338 342 Returns
339 343 -------
340 344 The actual gui used (if not given as input, it was obtained from matplotlib
@@ -356,12 +360,11 b' def pylab_activate(user_ns, gui=None, import_all=True, shell=None):'
356 360 import_pylab(user_ns, import_all)
357 361 if shell is not None:
358 362 configure_inline_support(shell, backend, user_ns)
359
360 print """
363 if welcome_message:
364 print """
361 365 Welcome to pylab, a matplotlib-based Python environment [backend: %s].
362 366 For more information, type 'help(pylab)'.""" % backend
363 # flush stdout, just to be safe
364 sys.stdout.flush()
365
366 return gui
367 # flush stdout, just to be safe
368 sys.stdout.flush()
367 369
370 return gui
@@ -197,7 +197,7 b' class InteractiveShellApp(Configurable):'
197 197 gui, backend = pylabtools.find_gui_and_backend(self.pylab)
198 198 self.log.info("Enabling GUI event loop integration, "
199 199 "toolkit=%s, pylab=%s" % (gui, self.pylab))
200 shell.enable_pylab(gui, import_all=self.pylab_import_all)
200 shell.enable_pylab(gui, import_all=self.pylab_import_all, welcome_message=True)
201 201 else:
202 202 self.log.info("Enabling GUI event loop integration, "
203 203 "toolkit=%s" % self.gui)
General Comments 0
You need to be logged in to leave comments. Login now