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