Show More
@@ -458,7 +458,11 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
458 | # code in an empty namespace, and we update *both* user_ns and |
|
458 | # code in an empty namespace, and we update *both* user_ns and | |
459 | # user_ns_hidden with this information. |
|
459 | # user_ns_hidden with this information. | |
460 | ns = {} |
|
460 | ns = {} | |
461 | gui = pylab_activate(ns, gui, import_all) |
|
461 | try: | |
|
462 | gui = pylab_activate(ns, gui, import_all) | |||
|
463 | except KeyError: | |||
|
464 | error("Backend %r not supported" % gui) | |||
|
465 | return | |||
462 | self.user_ns.update(ns) |
|
466 | self.user_ns.update(ns) | |
463 | self.user_ns_hidden.update(ns) |
|
467 | self.user_ns_hidden.update(ns) | |
464 | # Now we must activate the gui pylab wants to use, and fix %run to take |
|
468 | # Now we must activate the gui pylab wants to use, and fix %run to take |
@@ -196,7 +196,7 b' def find_gui_and_backend(gui=None):' | |||||
196 |
|
196 | |||
197 | import matplotlib |
|
197 | import matplotlib | |
198 |
|
198 | |||
199 | if gui: |
|
199 | if gui and gui != 'auto': | |
200 | # select backend based on requested gui |
|
200 | # select backend based on requested gui | |
201 | backend = backends[gui] |
|
201 | backend = backends[gui] | |
202 | else: |
|
202 | else: |
@@ -740,8 +740,7 b' class IPKernelApp(KernelApp, InteractiveShellApp):' | |||||
740 | kernel_factory = Kernel |
|
740 | kernel_factory = Kernel | |
741 |
|
741 | |||
742 | if self.pylab: |
|
742 | if self.pylab: | |
743 | key = None if self.pylab == 'auto' else self.pylab |
|
743 | gui, backend = pylabtools.find_gui_and_backend(self.pylab) | |
744 | gui, backend = pylabtools.find_gui_and_backend(key) |
|
|||
745 |
|
744 | |||
746 | kernel = kernel_factory(config=self.config, session=self.session, |
|
745 | kernel = kernel_factory(config=self.config, session=self.session, | |
747 | shell_socket=self.shell_socket, |
|
746 | shell_socket=self.shell_socket, |
@@ -414,7 +414,12 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
414 | from IPython.zmq.ipkernel import enable_gui |
|
414 | from IPython.zmq.ipkernel import enable_gui | |
415 | opts, arg = self.parse_options(parameter_s, '') |
|
415 | opts, arg = self.parse_options(parameter_s, '') | |
416 | if arg=='': arg = None |
|
416 | if arg=='': arg = None | |
417 | return enable_gui(arg) |
|
417 | try: | |
|
418 | enable_gui(arg) | |||
|
419 | except Exception as e: | |||
|
420 | # print simple error message, rather than traceback if we can't | |||
|
421 | # hook up the GUI | |||
|
422 | error(str(e)) | |||
418 |
|
423 | |||
419 | def enable_pylab(self, gui=None, import_all=True): |
|
424 | def enable_pylab(self, gui=None, import_all=True): | |
420 | """Activate pylab support at runtime. |
|
425 | """Activate pylab support at runtime. | |
@@ -440,13 +445,21 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
440 | # code in an empty namespace, and we update *both* user_ns and |
|
445 | # code in an empty namespace, and we update *both* user_ns and | |
441 | # user_ns_hidden with this information. |
|
446 | # user_ns_hidden with this information. | |
442 | ns = {} |
|
447 | ns = {} | |
443 | # override default to inline, from auto-detect |
|
448 | try: | |
444 |
gui = pylabtools.pylab_activate(ns, gui |
|
449 | gui = pylabtools.pylab_activate(ns, gui, import_all, self) | |
|
450 | except KeyError: | |||
|
451 | error("Backend %r not supported" % gui) | |||
|
452 | return | |||
445 | self.user_ns.update(ns) |
|
453 | self.user_ns.update(ns) | |
446 | self.user_ns_hidden.update(ns) |
|
454 | self.user_ns_hidden.update(ns) | |
447 | # Now we must activate the gui pylab wants to use, and fix %run to take |
|
455 | # Now we must activate the gui pylab wants to use, and fix %run to take | |
448 | # plot updates into account |
|
456 | # plot updates into account | |
449 | enable_gui(gui) |
|
457 | try: | |
|
458 | enable_gui(gui) | |||
|
459 | except Exception as e: | |||
|
460 | # print simple error message, rather than traceback if we can't | |||
|
461 | # hook up the GUI | |||
|
462 | error(str(e)) | |||
450 | self.magic_run = self._pylab_magic_run |
|
463 | self.magic_run = self._pylab_magic_run | |
451 |
|
464 | |||
452 |
|
465 |
General Comments 0
You need to be logged in to leave comments.
Login now