From 05664254c1d2cb86f260c7f5ea6bc62352254886 2014-09-18 18:03:07 From: Thomas Kluyver Date: 2014-09-18 18:03:07 Subject: [PATCH] Deprecation warnings for enable_* functions in inputhook Also, update examples to not use these --- diff --git a/IPython/lib/inputhook.py b/IPython/lib/inputhook.py index fffe97b..95973a8 100644 --- a/IPython/lib/inputhook.py +++ b/IPython/lib/inputhook.py @@ -549,12 +549,21 @@ register = inputhook_manager.register guis = inputhook_manager.guihooks # Deprecated methods: kept for backwards compatibility, do not use in new code -enable_wx = lambda app=None: inputhook_manager.enable_gui('wx', app) -enable_qt4 = lambda app=None: inputhook_manager.enable_gui('qt4', app) -enable_gtk = lambda app=None: inputhook_manager.enable_gui('gtk', app) -enable_tk = lambda app=None: inputhook_manager.enable_gui('tk', app) -enable_glut = lambda app=None: inputhook_manager.enable_gui('glut', app) -enable_pyglet = lambda app=None: inputhook_manager.enable_gui('pyglet', app) -enable_gtk3 = lambda app=None: inputhook_manager.enable_gui('gtk3', app) +def _make_deprecated_enable(name): + def enable_toolkit(app=None): + warn("This function is deprecated - use enable_gui(%r) instead" % name) + inputhook_manager.enable_gui(name, app) + +enable_wx = _make_deprecated_enable('wx') +enable_qt4 = _make_deprecated_enable('qt4') +enable_gtk = _make_deprecated_enable('gtk') +enable_tk = _make_deprecated_enable('tk') +enable_glut = _make_deprecated_enable('glut') +enable_pyglet = _make_deprecated_enable('pyglet') +enable_gtk3 = _make_deprecated_enable('gtk3') + +def _deprecated_disable(): + warn("This function is deprecated: use disable_gui() instead") + inputhook_manager.disable_gui() disable_wx = disable_qt4 = disable_gtk = disable_gtk3 = disable_glut = \ - disable_pyglet = inputhook_manager.disable_gui \ No newline at end of file + disable_pyglet = _deprecated_disable diff --git a/examples/IPython Kernel/gui/gui-gtk.py b/examples/IPython Kernel/gui/gui-gtk.py index 64d364f..80d888a 100755 --- a/examples/IPython Kernel/gui/gui-gtk.py +++ b/examples/IPython Kernel/gui/gui-gtk.py @@ -33,7 +33,7 @@ button.show() window.show() try: - from IPython.lib.inputhook import enable_gtk - enable_gtk() + from IPython.lib.inputhook import enable_gui + enable_gui('gtk') except ImportError: gtk.main() diff --git a/examples/IPython Kernel/gui/gui-gtk3.py b/examples/IPython Kernel/gui/gui-gtk3.py index 2e27320..1ee7c98 100644 --- a/examples/IPython Kernel/gui/gui-gtk3.py +++ b/examples/IPython Kernel/gui/gui-gtk3.py @@ -31,7 +31,7 @@ button.show() window.show() try: - from IPython.lib.inputhook import enable_gtk3 - enable_gtk3() + from IPython.lib.inputhook import enable_gui + enable_gui('gtk3') except ImportError: Gtk.main() diff --git a/examples/IPython Kernel/gui/gui-pyglet.py b/examples/IPython Kernel/gui/gui-pyglet.py index 3bdb699..f641622 100644 --- a/examples/IPython Kernel/gui/gui-pyglet.py +++ b/examples/IPython Kernel/gui/gui-pyglet.py @@ -27,7 +27,7 @@ def on_draw(): label.draw() try: - from IPython.lib.inputhook import enable_pyglet - enable_pyglet() + from IPython.lib.inputhook import enable_gui + enable_gui('pyglet') except ImportError: pyglet.app.run() diff --git a/examples/IPython Kernel/gui/gui-tk.py b/examples/IPython Kernel/gui/gui-tk.py index 681e003..a83bff0 100755 --- a/examples/IPython Kernel/gui/gui-tk.py +++ b/examples/IPython Kernel/gui/gui-tk.py @@ -30,6 +30,7 @@ root = Tk() app = MyApp(root) try: - from IPython.lib.inputhook import enable_tk; enable_tk(root) + from IPython.lib.inputhook import enable_gui + enable_gui('tk', root) except ImportError: root.mainloop() diff --git a/examples/IPython Kernel/gui/gui-wx.py b/examples/IPython Kernel/gui/gui-wx.py index 53c4d21..86e37ac 100755 --- a/examples/IPython Kernel/gui/gui-wx.py +++ b/examples/IPython Kernel/gui/gui-wx.py @@ -100,7 +100,7 @@ if __name__ == '__main__': frame.Show(True) try: - from IPython.lib.inputhook import enable_wx - enable_wx(app) + from IPython.lib.inputhook import enable_gui + enable_gui('wx', app) except ImportError: app.MainLoop()