inputhook.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. # coding: utf-8
  2. """
  3. Deprecated since IPython 5.0
  4. Inputhook management for GUI event loop integration.
  5. """
  6. # Copyright (c) IPython Development Team.
  7. # Distributed under the terms of the Modified BSD License.
  8. try:
  9. import ctypes
  10. except ImportError:
  11. ctypes = None
  12. except SystemError: # IronPython issue, 2/8/2014
  13. ctypes = None
  14. import os
  15. import platform
  16. import sys
  17. from distutils.version import LooseVersion as V
  18. from warnings import warn
  19. warn("`IPython.lib.inputhook` is deprecated since IPython 5.0 and will be removed in future versions.",
  20. DeprecationWarning, stacklevel=2)
  21. #-----------------------------------------------------------------------------
  22. # Constants
  23. #-----------------------------------------------------------------------------
  24. # Constants for identifying the GUI toolkits.
  25. GUI_WX = 'wx'
  26. GUI_QT = 'qt'
  27. GUI_QT4 = 'qt4'
  28. GUI_GTK = 'gtk'
  29. GUI_TK = 'tk'
  30. GUI_OSX = 'osx'
  31. GUI_GLUT = 'glut'
  32. GUI_PYGLET = 'pyglet'
  33. GUI_GTK3 = 'gtk3'
  34. GUI_NONE = 'none' # i.e. disable
  35. #-----------------------------------------------------------------------------
  36. # Utilities
  37. #-----------------------------------------------------------------------------
  38. def _stdin_ready_posix():
  39. """Return True if there's something to read on stdin (posix version)."""
  40. infds, outfds, erfds = select.select([sys.stdin],[],[],0)
  41. return bool(infds)
  42. def _stdin_ready_nt():
  43. """Return True if there's something to read on stdin (nt version)."""
  44. return msvcrt.kbhit()
  45. def _stdin_ready_other():
  46. """Return True, assuming there's something to read on stdin."""
  47. return True
  48. def _use_appnope():
  49. """Should we use appnope for dealing with OS X app nap?
  50. Checks if we are on OS X 10.9 or greater.
  51. """
  52. return sys.platform == 'darwin' and V(platform.mac_ver()[0]) >= V('10.9')
  53. def _ignore_CTRL_C_posix():
  54. """Ignore CTRL+C (SIGINT)."""
  55. signal.signal(signal.SIGINT, signal.SIG_IGN)
  56. def _allow_CTRL_C_posix():
  57. """Take CTRL+C into account (SIGINT)."""
  58. signal.signal(signal.SIGINT, signal.default_int_handler)
  59. def _ignore_CTRL_C_other():
  60. """Ignore CTRL+C (not implemented)."""
  61. pass
  62. def _allow_CTRL_C_other():
  63. """Take CTRL+C into account (not implemented)."""
  64. pass
  65. if os.name == 'posix':
  66. import select
  67. import signal
  68. stdin_ready = _stdin_ready_posix
  69. ignore_CTRL_C = _ignore_CTRL_C_posix
  70. allow_CTRL_C = _allow_CTRL_C_posix
  71. elif os.name == 'nt':
  72. import msvcrt
  73. stdin_ready = _stdin_ready_nt
  74. ignore_CTRL_C = _ignore_CTRL_C_other
  75. allow_CTRL_C = _allow_CTRL_C_other
  76. else:
  77. stdin_ready = _stdin_ready_other
  78. ignore_CTRL_C = _ignore_CTRL_C_other
  79. allow_CTRL_C = _allow_CTRL_C_other
  80. #-----------------------------------------------------------------------------
  81. # Main InputHookManager class
  82. #-----------------------------------------------------------------------------
  83. class InputHookManager(object):
  84. """DEPRECATED since IPython 5.0
  85. Manage PyOS_InputHook for different GUI toolkits.
  86. This class installs various hooks under ``PyOSInputHook`` to handle
  87. GUI event loop integration.
  88. """
  89. def __init__(self):
  90. if ctypes is None:
  91. warn("IPython GUI event loop requires ctypes, %gui will not be available")
  92. else:
  93. self.PYFUNC = ctypes.PYFUNCTYPE(ctypes.c_int)
  94. self.guihooks = {}
  95. self.aliases = {}
  96. self.apps = {}
  97. self._reset()
  98. def _reset(self):
  99. self._callback_pyfunctype = None
  100. self._callback = None
  101. self._installed = False
  102. self._current_gui = None
  103. def get_pyos_inputhook(self):
  104. """DEPRECATED since IPython 5.0
  105. Return the current PyOS_InputHook as a ctypes.c_void_p."""
  106. warn("`get_pyos_inputhook` is deprecated since IPython 5.0 and will be removed in future versions.",
  107. DeprecationWarning, stacklevel=2)
  108. return ctypes.c_void_p.in_dll(ctypes.pythonapi,"PyOS_InputHook")
  109. def get_pyos_inputhook_as_func(self):
  110. """DEPRECATED since IPython 5.0
  111. Return the current PyOS_InputHook as a ctypes.PYFUNCYPE."""
  112. warn("`get_pyos_inputhook_as_func` is deprecated since IPython 5.0 and will be removed in future versions.",
  113. DeprecationWarning, stacklevel=2)
  114. return self.PYFUNC.in_dll(ctypes.pythonapi,"PyOS_InputHook")
  115. def set_inputhook(self, callback):
  116. """DEPRECATED since IPython 5.0
  117. Set PyOS_InputHook to callback and return the previous one."""
  118. # On platforms with 'readline' support, it's all too likely to
  119. # have a KeyboardInterrupt signal delivered *even before* an
  120. # initial ``try:`` clause in the callback can be executed, so
  121. # we need to disable CTRL+C in this situation.
  122. ignore_CTRL_C()
  123. self._callback = callback
  124. self._callback_pyfunctype = self.PYFUNC(callback)
  125. pyos_inputhook_ptr = self.get_pyos_inputhook()
  126. original = self.get_pyos_inputhook_as_func()
  127. pyos_inputhook_ptr.value = \
  128. ctypes.cast(self._callback_pyfunctype, ctypes.c_void_p).value
  129. self._installed = True
  130. return original
  131. def clear_inputhook(self, app=None):
  132. """DEPRECATED since IPython 5.0
  133. Set PyOS_InputHook to NULL and return the previous one.
  134. Parameters
  135. ----------
  136. app : optional, ignored
  137. This parameter is allowed only so that clear_inputhook() can be
  138. called with a similar interface as all the ``enable_*`` methods. But
  139. the actual value of the parameter is ignored. This uniform interface
  140. makes it easier to have user-level entry points in the main IPython
  141. app like :meth:`enable_gui`."""
  142. warn("`clear_inputhook` is deprecated since IPython 5.0 and will be removed in future versions.",
  143. DeprecationWarning, stacklevel=2)
  144. pyos_inputhook_ptr = self.get_pyos_inputhook()
  145. original = self.get_pyos_inputhook_as_func()
  146. pyos_inputhook_ptr.value = ctypes.c_void_p(None).value
  147. allow_CTRL_C()
  148. self._reset()
  149. return original
  150. def clear_app_refs(self, gui=None):
  151. """DEPRECATED since IPython 5.0
  152. Clear IPython's internal reference to an application instance.
  153. Whenever we create an app for a user on qt4 or wx, we hold a
  154. reference to the app. This is needed because in some cases bad things
  155. can happen if a user doesn't hold a reference themselves. This
  156. method is provided to clear the references we are holding.
  157. Parameters
  158. ----------
  159. gui : None or str
  160. If None, clear all app references. If ('wx', 'qt4') clear
  161. the app for that toolkit. References are not held for gtk or tk
  162. as those toolkits don't have the notion of an app.
  163. """
  164. warn("`clear_app_refs` is deprecated since IPython 5.0 and will be removed in future versions.",
  165. DeprecationWarning, stacklevel=2)
  166. if gui is None:
  167. self.apps = {}
  168. elif gui in self.apps:
  169. del self.apps[gui]
  170. def register(self, toolkitname, *aliases):
  171. """DEPRECATED since IPython 5.0
  172. Register a class to provide the event loop for a given GUI.
  173. This is intended to be used as a class decorator. It should be passed
  174. the names with which to register this GUI integration. The classes
  175. themselves should subclass :class:`InputHookBase`.
  176. ::
  177. @inputhook_manager.register('qt')
  178. class QtInputHook(InputHookBase):
  179. def enable(self, app=None):
  180. ...
  181. """
  182. warn("`register` is deprecated since IPython 5.0 and will be removed in future versions.",
  183. DeprecationWarning, stacklevel=2)
  184. def decorator(cls):
  185. if ctypes is not None:
  186. inst = cls(self)
  187. self.guihooks[toolkitname] = inst
  188. for a in aliases:
  189. self.aliases[a] = toolkitname
  190. return cls
  191. return decorator
  192. def current_gui(self):
  193. """DEPRECATED since IPython 5.0
  194. Return a string indicating the currently active GUI or None."""
  195. warn("`current_gui` is deprecated since IPython 5.0 and will be removed in future versions.",
  196. DeprecationWarning, stacklevel=2)
  197. return self._current_gui
  198. def enable_gui(self, gui=None, app=None):
  199. """DEPRECATED since IPython 5.0
  200. Switch amongst GUI input hooks by name.
  201. This is a higher level method than :meth:`set_inputhook` - it uses the
  202. GUI name to look up a registered object which enables the input hook
  203. for that GUI.
  204. Parameters
  205. ----------
  206. gui : optional, string or None
  207. If None (or 'none'), clears input hook, otherwise it must be one
  208. of the recognized GUI names (see ``GUI_*`` constants in module).
  209. app : optional, existing application object.
  210. For toolkits that have the concept of a global app, you can supply an
  211. existing one. If not given, the toolkit will be probed for one, and if
  212. none is found, a new one will be created. Note that GTK does not have
  213. this concept, and passing an app if ``gui=="GTK"`` will raise an error.
  214. Returns
  215. -------
  216. The output of the underlying gui switch routine, typically the actual
  217. PyOS_InputHook wrapper object or the GUI toolkit app created, if there was
  218. one.
  219. """
  220. warn("`enable_gui` is deprecated since IPython 5.0 and will be removed in future versions.",
  221. DeprecationWarning, stacklevel=2)
  222. if gui in (None, GUI_NONE):
  223. return self.disable_gui()
  224. if gui in self.aliases:
  225. return self.enable_gui(self.aliases[gui], app)
  226. try:
  227. gui_hook = self.guihooks[gui]
  228. except KeyError:
  229. e = "Invalid GUI request {!r}, valid ones are: {}"
  230. raise ValueError(e.format(gui, ', '.join(self.guihooks)))
  231. self._current_gui = gui
  232. app = gui_hook.enable(app)
  233. if app is not None:
  234. app._in_event_loop = True
  235. self.apps[gui] = app
  236. return app
  237. def disable_gui(self):
  238. """DEPRECATED since IPython 5.0
  239. Disable GUI event loop integration.
  240. If an application was registered, this sets its ``_in_event_loop``
  241. attribute to False. It then calls :meth:`clear_inputhook`.
  242. """
  243. warn("`disable_gui` is deprecated since IPython 5.0 and will be removed in future versions.",
  244. DeprecationWarning, stacklevel=2)
  245. gui = self._current_gui
  246. if gui in self.apps:
  247. self.apps[gui]._in_event_loop = False
  248. return self.clear_inputhook()
  249. class InputHookBase(object):
  250. """DEPRECATED since IPython 5.0
  251. Base class for input hooks for specific toolkits.
  252. Subclasses should define an :meth:`enable` method with one argument, ``app``,
  253. which will either be an instance of the toolkit's application class, or None.
  254. They may also define a :meth:`disable` method with no arguments.
  255. """
  256. def __init__(self, manager):
  257. self.manager = manager
  258. def disable(self):
  259. pass
  260. inputhook_manager = InputHookManager()
  261. @inputhook_manager.register('osx')
  262. class NullInputHook(InputHookBase):
  263. """DEPRECATED since IPython 5.0
  264. A null inputhook that doesn't need to do anything"""
  265. def enable(self, app=None):
  266. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  267. DeprecationWarning, stacklevel=2)
  268. @inputhook_manager.register('wx')
  269. class WxInputHook(InputHookBase):
  270. def enable(self, app=None):
  271. """DEPRECATED since IPython 5.0
  272. Enable event loop integration with wxPython.
  273. Parameters
  274. ----------
  275. app : WX Application, optional.
  276. Running application to use. If not given, we probe WX for an
  277. existing application object, and create a new one if none is found.
  278. Notes
  279. -----
  280. This methods sets the ``PyOS_InputHook`` for wxPython, which allows
  281. the wxPython to integrate with terminal based applications like
  282. IPython.
  283. If ``app`` is not given we probe for an existing one, and return it if
  284. found. If no existing app is found, we create an :class:`wx.App` as
  285. follows::
  286. import wx
  287. app = wx.App(redirect=False, clearSigInt=False)
  288. """
  289. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  290. DeprecationWarning, stacklevel=2)
  291. import wx
  292. wx_version = V(wx.__version__).version
  293. if wx_version < [2, 8]:
  294. raise ValueError("requires wxPython >= 2.8, but you have %s" % wx.__version__)
  295. from IPython.lib.inputhookwx import inputhook_wx
  296. self.manager.set_inputhook(inputhook_wx)
  297. if _use_appnope():
  298. from appnope import nope
  299. nope()
  300. import wx
  301. if app is None:
  302. app = wx.GetApp()
  303. if app is None:
  304. app = wx.App(redirect=False, clearSigInt=False)
  305. return app
  306. def disable(self):
  307. """DEPRECATED since IPython 5.0
  308. Disable event loop integration with wxPython.
  309. This restores appnapp on OS X
  310. """
  311. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  312. DeprecationWarning, stacklevel=2)
  313. if _use_appnope():
  314. from appnope import nap
  315. nap()
  316. @inputhook_manager.register('qt', 'qt4')
  317. class Qt4InputHook(InputHookBase):
  318. def enable(self, app=None):
  319. """DEPRECATED since IPython 5.0
  320. Enable event loop integration with PyQt4.
  321. Parameters
  322. ----------
  323. app : Qt Application, optional.
  324. Running application to use. If not given, we probe Qt for an
  325. existing application object, and create a new one if none is found.
  326. Notes
  327. -----
  328. This methods sets the PyOS_InputHook for PyQt4, which allows
  329. the PyQt4 to integrate with terminal based applications like
  330. IPython.
  331. If ``app`` is not given we probe for an existing one, and return it if
  332. found. If no existing app is found, we create an :class:`QApplication`
  333. as follows::
  334. from PyQt4 import QtCore
  335. app = QtGui.QApplication(sys.argv)
  336. """
  337. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  338. DeprecationWarning, stacklevel=2)
  339. from IPython.lib.inputhookqt4 import create_inputhook_qt4
  340. app, inputhook_qt4 = create_inputhook_qt4(self.manager, app)
  341. self.manager.set_inputhook(inputhook_qt4)
  342. if _use_appnope():
  343. from appnope import nope
  344. nope()
  345. return app
  346. def disable_qt4(self):
  347. """DEPRECATED since IPython 5.0
  348. Disable event loop integration with PyQt4.
  349. This restores appnapp on OS X
  350. """
  351. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  352. DeprecationWarning, stacklevel=2)
  353. if _use_appnope():
  354. from appnope import nap
  355. nap()
  356. @inputhook_manager.register('qt5')
  357. class Qt5InputHook(Qt4InputHook):
  358. def enable(self, app=None):
  359. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  360. DeprecationWarning, stacklevel=2)
  361. os.environ['QT_API'] = 'pyqt5'
  362. return Qt4InputHook.enable(self, app)
  363. @inputhook_manager.register('gtk')
  364. class GtkInputHook(InputHookBase):
  365. def enable(self, app=None):
  366. """DEPRECATED since IPython 5.0
  367. Enable event loop integration with PyGTK.
  368. Parameters
  369. ----------
  370. app : ignored
  371. Ignored, it's only a placeholder to keep the call signature of all
  372. gui activation methods consistent, which simplifies the logic of
  373. supporting magics.
  374. Notes
  375. -----
  376. This methods sets the PyOS_InputHook for PyGTK, which allows
  377. the PyGTK to integrate with terminal based applications like
  378. IPython.
  379. """
  380. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  381. DeprecationWarning, stacklevel=2)
  382. import gtk
  383. try:
  384. gtk.set_interactive(True)
  385. except AttributeError:
  386. # For older versions of gtk, use our own ctypes version
  387. from IPython.lib.inputhookgtk import inputhook_gtk
  388. self.manager.set_inputhook(inputhook_gtk)
  389. @inputhook_manager.register('tk')
  390. class TkInputHook(InputHookBase):
  391. def enable(self, app=None):
  392. """DEPRECATED since IPython 5.0
  393. Enable event loop integration with Tk.
  394. Parameters
  395. ----------
  396. app : toplevel :class:`Tkinter.Tk` widget, optional.
  397. Running toplevel widget to use. If not given, we probe Tk for an
  398. existing one, and create a new one if none is found.
  399. Notes
  400. -----
  401. If you have already created a :class:`Tkinter.Tk` object, the only
  402. thing done by this method is to register with the
  403. :class:`InputHookManager`, since creating that object automatically
  404. sets ``PyOS_InputHook``.
  405. """
  406. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  407. DeprecationWarning, stacklevel=2)
  408. if app is None:
  409. try:
  410. from tkinter import Tk # Py 3
  411. except ImportError:
  412. from Tkinter import Tk # Py 2
  413. app = Tk()
  414. app.withdraw()
  415. self.manager.apps[GUI_TK] = app
  416. return app
  417. @inputhook_manager.register('glut')
  418. class GlutInputHook(InputHookBase):
  419. def enable(self, app=None):
  420. """DEPRECATED since IPython 5.0
  421. Enable event loop integration with GLUT.
  422. Parameters
  423. ----------
  424. app : ignored
  425. Ignored, it's only a placeholder to keep the call signature of all
  426. gui activation methods consistent, which simplifies the logic of
  427. supporting magics.
  428. Notes
  429. -----
  430. This methods sets the PyOS_InputHook for GLUT, which allows the GLUT to
  431. integrate with terminal based applications like IPython. Due to GLUT
  432. limitations, it is currently not possible to start the event loop
  433. without first creating a window. You should thus not create another
  434. window but use instead the created one. See 'gui-glut.py' in the
  435. docs/examples/lib directory.
  436. The default screen mode is set to:
  437. glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH
  438. """
  439. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  440. DeprecationWarning, stacklevel=2)
  441. import OpenGL.GLUT as glut
  442. from IPython.lib.inputhookglut import glut_display_mode, \
  443. glut_close, glut_display, \
  444. glut_idle, inputhook_glut
  445. if GUI_GLUT not in self.manager.apps:
  446. glut.glutInit( sys.argv )
  447. glut.glutInitDisplayMode( glut_display_mode )
  448. # This is specific to freeglut
  449. if bool(glut.glutSetOption):
  450. glut.glutSetOption( glut.GLUT_ACTION_ON_WINDOW_CLOSE,
  451. glut.GLUT_ACTION_GLUTMAINLOOP_RETURNS )
  452. glut.glutCreateWindow( sys.argv[0] )
  453. glut.glutReshapeWindow( 1, 1 )
  454. glut.glutHideWindow( )
  455. glut.glutWMCloseFunc( glut_close )
  456. glut.glutDisplayFunc( glut_display )
  457. glut.glutIdleFunc( glut_idle )
  458. else:
  459. glut.glutWMCloseFunc( glut_close )
  460. glut.glutDisplayFunc( glut_display )
  461. glut.glutIdleFunc( glut_idle)
  462. self.manager.set_inputhook( inputhook_glut )
  463. def disable(self):
  464. """DEPRECATED since IPython 5.0
  465. Disable event loop integration with glut.
  466. This sets PyOS_InputHook to NULL and set the display function to a
  467. dummy one and set the timer to a dummy timer that will be triggered
  468. very far in the future.
  469. """
  470. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  471. DeprecationWarning, stacklevel=2)
  472. import OpenGL.GLUT as glut
  473. from glut_support import glutMainLoopEvent
  474. glut.glutHideWindow() # This is an event to be processed below
  475. glutMainLoopEvent()
  476. super(GlutInputHook, self).disable()
  477. @inputhook_manager.register('pyglet')
  478. class PygletInputHook(InputHookBase):
  479. def enable(self, app=None):
  480. """DEPRECATED since IPython 5.0
  481. Enable event loop integration with pyglet.
  482. Parameters
  483. ----------
  484. app : ignored
  485. Ignored, it's only a placeholder to keep the call signature of all
  486. gui activation methods consistent, which simplifies the logic of
  487. supporting magics.
  488. Notes
  489. -----
  490. This methods sets the ``PyOS_InputHook`` for pyglet, which allows
  491. pyglet to integrate with terminal based applications like
  492. IPython.
  493. """
  494. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  495. DeprecationWarning, stacklevel=2)
  496. from IPython.lib.inputhookpyglet import inputhook_pyglet
  497. self.manager.set_inputhook(inputhook_pyglet)
  498. return app
  499. @inputhook_manager.register('gtk3')
  500. class Gtk3InputHook(InputHookBase):
  501. def enable(self, app=None):
  502. """DEPRECATED since IPython 5.0
  503. Enable event loop integration with Gtk3 (gir bindings).
  504. Parameters
  505. ----------
  506. app : ignored
  507. Ignored, it's only a placeholder to keep the call signature of all
  508. gui activation methods consistent, which simplifies the logic of
  509. supporting magics.
  510. Notes
  511. -----
  512. This methods sets the PyOS_InputHook for Gtk3, which allows
  513. the Gtk3 to integrate with terminal based applications like
  514. IPython.
  515. """
  516. warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
  517. DeprecationWarning, stacklevel=2)
  518. from IPython.lib.inputhookgtk3 import inputhook_gtk3
  519. self.manager.set_inputhook(inputhook_gtk3)
  520. clear_inputhook = inputhook_manager.clear_inputhook
  521. set_inputhook = inputhook_manager.set_inputhook
  522. current_gui = inputhook_manager.current_gui
  523. clear_app_refs = inputhook_manager.clear_app_refs
  524. enable_gui = inputhook_manager.enable_gui
  525. disable_gui = inputhook_manager.disable_gui
  526. register = inputhook_manager.register
  527. guis = inputhook_manager.guihooks
  528. def _deprecated_disable():
  529. warn("This function is deprecated since IPython 4.0 use disable_gui() instead",
  530. DeprecationWarning, stacklevel=2)
  531. inputhook_manager.disable_gui()
  532. disable_wx = disable_qt4 = disable_gtk = disable_gtk3 = disable_glut = \
  533. disable_pyglet = disable_osx = _deprecated_disable