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

Function find_gui_and_backend

IPython/core/pylabtools.py:263–303  ·  view source on GitHub ↗

Given a gui string return the gui and mpl backend. Parameters ---------- gui : str Can be one of ('tk','gtk','wx','qt','qt4','inline','agg'). gui_select : str Can be one of ('tk','gtk','wx','qt','qt4','inline'). This is any gui already selected by the shell.

(gui=None, gui_select=None)

Source from the content-addressed store, hash-verified

261
262
263def find_gui_and_backend(gui=None, gui_select=None):
264 """Given a gui string return the gui and mpl backend.
265
266 Parameters
267 ----------
268 gui : str
269 Can be one of ('tk','gtk','wx','qt','qt4','inline','agg').
270 gui_select : str
271 Can be one of ('tk','gtk','wx','qt','qt4','inline').
272 This is any gui already selected by the shell.
273
274 Returns
275 -------
276 A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg',
277 'WXAgg','Qt4Agg','module://ipykernel.pylab.backend_inline','agg').
278 """
279
280 import matplotlib
281
282 if gui and gui != 'auto':
283 # select backend based on requested gui
284 backend = backends[gui]
285 if gui == 'agg':
286 gui = None
287 else:
288 # We need to read the backend from the original data structure, *not*
289 # from mpl.rcParams, since a prior invocation of %matplotlib may have
290 # overwritten that.
291 # WARNING: this assumes matplotlib 1.1 or newer!!
292 backend = matplotlib.rcParamsOrig['backend']
293 # In this case, we need to find what the appropriate gui selection call
294 # should be for IPython, so we can activate inputhook accordingly
295 gui = backend2gui.get(backend, None)
296
297 # If we have already had a gui active, we need it and inline are the
298 # ones allowed.
299 if gui_select and gui != gui_select:
300 gui = gui_select
301 backend = backends[gui]
302
303 return gui, backend
304
305
306def activate_matplotlib(backend):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected