MCPcopy Create free account
hub / github.com/ipython/ipython / init_gui_pylab

Method init_gui_pylab

IPython/core/shellapp.py:220–257  ·  view source on GitHub ↗

Enable GUI event loop integration, taking pylab into account.

(self)

Source from the content-addressed store, hash-verified

218 raise NotImplementedError("Override in subclasses")
219
220 def init_gui_pylab(self):
221 """Enable GUI event loop integration, taking pylab into account."""
222 enable = False
223 shell = self.shell
224 if self.pylab:
225 enable = lambda key: shell.enable_pylab(key, import_all=self.pylab_import_all)
226 key = self.pylab
227 elif self.matplotlib:
228 enable = shell.enable_matplotlib
229 key = self.matplotlib
230 elif self.gui:
231 enable = shell.enable_gui
232 key = self.gui
233
234 if not enable:
235 return
236
237 try:
238 r = enable(key)
239 except ImportError:
240 self.log.warning("Eventloop or matplotlib integration failed. Is matplotlib installed?")
241 self.shell.showtraceback()
242 return
243 except Exception:
244 self.log.warning("GUI event loop or pylab initialization failed")
245 self.shell.showtraceback()
246 return
247
248 if isinstance(r, tuple):
249 gui, backend = r[:2]
250 self.log.info("Enabling GUI event loop integration, "
251 "eventloop=%s, matplotlib=%s", gui, backend)
252 if key == "auto":
253 print("Using matplotlib backend: %s" % backend)
254 else:
255 gui = r
256 self.log.info("Enabling GUI event loop integration, "
257 "eventloop=%s", gui)
258
259 def init_extensions(self):
260 """Load all IPython extensions in IPythonApp.extensions.

Callers 1

initializeMethod · 0.80

Calls 3

enable_pylabMethod · 0.80
showtracebackMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected