diff --git a/IPython/html/widgets/widget_link.py b/IPython/html/widgets/widget_link.py index 95970a3..d38c116 100644 --- a/IPython/html/widgets/widget_link.py +++ b/IPython/html/widgets/widget_link.py @@ -1,10 +1,9 @@ """Link and DirectionalLink classes. -Represents a button in the frontend using a widget. Allows user to listen for -click events on the button and trigger backend code when the clicks are fired. +Propagate changes between widgets on the javascript side """ #----------------------------------------------------------------------------- -# Copyright (c) 2013, the IPython Development Team. +# Copyright (c) 2014, the IPython Development Team. # # Distributed under the terms of the Modified BSD License. # @@ -31,6 +30,10 @@ class Link(Widget): kwargs['widgets'] = widgets super(Link, self).__init__(**kwargs) + # for compatibility with traitlet links + def unlink(self): + self.close() + def link(*args): return Link(widgets=args) @@ -49,6 +52,10 @@ class DirectionalLink(Widget): kwargs['targets'] = targets super(DirectionalLink, self).__init__(**kwargs) + # for compatibility with traitlet links + def unlink(self): + self.close() + def dlink(source, *targets): return DirectionalLink(source, targets) diff --git a/examples/Interactive Widgets/Widget Events.ipynb b/examples/Interactive Widgets/Widget Events.ipynb index 61df679..75cd86d 100644 --- a/examples/Interactive Widgets/Widget Events.ipynb +++ b/examples/Interactive Widgets/Widget Events.ipynb @@ -331,7 +331,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Function `widgets.link` returns a `Link` widget. The link can be broken by calling the `close` method." + "Function `widgets.link` returns a `Link` widget. The link can be broken by calling the `unlink` method." ] }, { @@ -342,7 +342,7 @@ }, "outputs": [], "source": [ - "# l.close()" + "# l.unlink()" ] }, { @@ -361,15 +361,22 @@ ] ], "kernelspec": { - "codemirror_mode": { - "name": "python", - "version": 2 - }, "display_name": "Python 2", - "language": "python", "name": "python2" }, - "signature": "sha256:05a3e92089b37f68e3134587ffef6ef73830e5f8b3c515ba24640d7c803820c3" + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.8" + }, + "signature": "sha256:b6eadc174d0d9c1907518d9f37760eb3dca3aec0ef1f3746e6f0537a36e99919" }, "nbformat": 4, "nbformat_minor": 0