Show More
@@ -458,7 +458,11 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
458 | 458 | # code in an empty namespace, and we update *both* user_ns and |
|
459 | 459 | # user_ns_hidden with this information. |
|
460 | 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 | 466 | self.user_ns.update(ns) |
|
463 | 467 | self.user_ns_hidden.update(ns) |
|
464 | 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 | 197 | import matplotlib |
|
198 | 198 | |
|
199 | if gui: | |
|
199 | if gui and gui != 'auto': | |
|
200 | 200 | # select backend based on requested gui |
|
201 | 201 | backend = backends[gui] |
|
202 | 202 | else: |
@@ -740,8 +740,7 b' class IPKernelApp(KernelApp, InteractiveShellApp):' | |||
|
740 | 740 | kernel_factory = Kernel |
|
741 | 741 | |
|
742 | 742 | if self.pylab: |
|
743 | key = None if self.pylab == 'auto' else self.pylab | |
|
744 | gui, backend = pylabtools.find_gui_and_backend(key) | |
|
743 | gui, backend = pylabtools.find_gui_and_backend(self.pylab) | |
|
745 | 744 | |
|
746 | 745 | kernel = kernel_factory(config=self.config, session=self.session, |
|
747 | 746 | shell_socket=self.shell_socket, |
@@ -414,7 +414,12 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
414 | 414 | from IPython.zmq.ipkernel import enable_gui |
|
415 | 415 | opts, arg = self.parse_options(parameter_s, '') |
|
416 | 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 | 424 | def enable_pylab(self, gui=None, import_all=True): |
|
420 | 425 | """Activate pylab support at runtime. |
@@ -440,13 +445,21 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
440 | 445 | # code in an empty namespace, and we update *both* user_ns and |
|
441 | 446 | # user_ns_hidden with this information. |
|
442 | 447 | ns = {} |
|
443 | # override default to inline, from auto-detect | |
|
444 |
gui = pylabtools.pylab_activate(ns, gui |
|
|
448 | try: | |
|
449 | gui = pylabtools.pylab_activate(ns, gui, import_all, self) | |
|
450 | except KeyError: | |
|
451 | error("Backend %r not supported" % gui) | |
|
452 | return | |
|
445 | 453 | self.user_ns.update(ns) |
|
446 | 454 | self.user_ns_hidden.update(ns) |
|
447 | 455 | # Now we must activate the gui pylab wants to use, and fix %run to take |
|
448 | 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 | 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