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

Method enable_gui

IPython/lib/inputhook.py:247–293  ·  view source on GitHub ↗

DEPRECATED since IPython 5.0 Switch amongst GUI input hooks by name. This is a higher level method than :meth:`set_inputhook` - it uses the GUI name to look up a registered object which enables the input hook for that GUI. Parameters ----------

(self, gui=None, app=None)

Source from the content-addressed store, hash-verified

245 return self._current_gui
246
247 def enable_gui(self, gui=None, app=None):
248 """DEPRECATED since IPython 5.0
249
250 Switch amongst GUI input hooks by name.
251
252 This is a higher level method than :meth:`set_inputhook` - it uses the
253 GUI name to look up a registered object which enables the input hook
254 for that GUI.
255
256 Parameters
257 ----------
258 gui : optional, string or None
259 If None (or 'none'), clears input hook, otherwise it must be one
260 of the recognized GUI names (see ``GUI_*`` constants in module).
261
262 app : optional, existing application object.
263 For toolkits that have the concept of a global app, you can supply an
264 existing one. If not given, the toolkit will be probed for one, and if
265 none is found, a new one will be created. Note that GTK does not have
266 this concept, and passing an app if ``gui=="GTK"`` will raise an error.
267
268 Returns
269 -------
270 The output of the underlying gui switch routine, typically the actual
271 PyOS_InputHook wrapper object or the GUI toolkit app created, if there was
272 one.
273 """
274 warn("`enable_gui` is deprecated since IPython 5.0 and will be removed in future versions.",
275 DeprecationWarning, stacklevel=2)
276 if gui in (None, GUI_NONE):
277 return self.disable_gui()
278
279 if gui in self.aliases:
280 return self.enable_gui(self.aliases[gui], app)
281
282 try:
283 gui_hook = self.guihooks[gui]
284 except KeyError:
285 e = "Invalid GUI request {!r}, valid ones are: {}"
286 raise ValueError(e.format(gui, ', '.join(self.guihooks)))
287 self._current_gui = gui
288
289 app = gui_hook.enable(app)
290 if app is not None:
291 app._in_event_loop = True
292 self.apps[gui] = app
293 return app
294
295 def disable_gui(self):
296 """DEPRECATED since IPython 5.0

Callers

nothing calls this directly

Calls 3

disable_guiMethod · 0.95
formatMethod · 0.45
enableMethod · 0.45

Tested by

no test coverage detected