##// END OF EJS Templates
Add the unlink method to javascript links to maintain compatibility with traitlet links
Jason Grout -
Show More
@@ -1,10 +1,9 b''
1 """Link and DirectionalLink classes.
1 """Link and DirectionalLink classes.
2
2
3 Represents a button in the frontend using a widget. Allows user to listen for
3 Propagate changes between widgets on the javascript side
4 click events on the button and trigger backend code when the clicks are fired.
5 """
4 """
6 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
7 # Copyright (c) 2013, the IPython Development Team.
6 # Copyright (c) 2014, the IPython Development Team.
8 #
7 #
9 # Distributed under the terms of the Modified BSD License.
8 # Distributed under the terms of the Modified BSD License.
10 #
9 #
@@ -31,6 +30,10 b' class Link(Widget):'
31 kwargs['widgets'] = widgets
30 kwargs['widgets'] = widgets
32 super(Link, self).__init__(**kwargs)
31 super(Link, self).__init__(**kwargs)
33
32
33 # for compatibility with traitlet links
34 def unlink(self):
35 self.close()
36
34
37
35 def link(*args):
38 def link(*args):
36 return Link(widgets=args)
39 return Link(widgets=args)
@@ -49,6 +52,10 b' class DirectionalLink(Widget):'
49 kwargs['targets'] = targets
52 kwargs['targets'] = targets
50 super(DirectionalLink, self).__init__(**kwargs)
53 super(DirectionalLink, self).__init__(**kwargs)
51
54
55 # for compatibility with traitlet links
56 def unlink(self):
57 self.close()
58
52
59
53 def dlink(source, *targets):
60 def dlink(source, *targets):
54 return DirectionalLink(source, targets)
61 return DirectionalLink(source, targets)
@@ -331,7 +331,7 b''
331 "cell_type": "markdown",
331 "cell_type": "markdown",
332 "metadata": {},
332 "metadata": {},
333 "source": [
333 "source": [
334 "Function `widgets.link` returns a `Link` widget. The link can be broken by calling the `close` method."
334 "Function `widgets.link` returns a `Link` widget. The link can be broken by calling the `unlink` method."
335 ]
335 ]
336 },
336 },
337 {
337 {
@@ -342,7 +342,7 b''
342 },
342 },
343 "outputs": [],
343 "outputs": [],
344 "source": [
344 "source": [
345 "# l.close()"
345 "# l.unlink()"
346 ]
346 ]
347 },
347 },
348 {
348 {
@@ -361,15 +361,22 b''
361 ]
361 ]
362 ],
362 ],
363 "kernelspec": {
363 "kernelspec": {
364 "codemirror_mode": {
365 "name": "python",
366 "version": 2
367 },
368 "display_name": "Python 2",
364 "display_name": "Python 2",
369 "language": "python",
370 "name": "python2"
365 "name": "python2"
371 },
366 },
372 "signature": "sha256:05a3e92089b37f68e3134587ffef6ef73830e5f8b3c515ba24640d7c803820c3"
367 "language_info": {
368 "codemirror_mode": {
369 "name": "ipython",
370 "version": 2
371 },
372 "file_extension": ".py",
373 "mimetype": "text/x-python",
374 "name": "python",
375 "nbconvert_exporter": "python",
376 "pygments_lexer": "ipython2",
377 "version": "2.7.8"
378 },
379 "signature": "sha256:b6eadc174d0d9c1907518d9f37760eb3dca3aec0ef1f3746e6f0537a36e99919"
373 },
380 },
374 "nbformat": 4,
381 "nbformat": 4,
375 "nbformat_minor": 0
382 "nbformat_minor": 0
General Comments 0
You need to be logged in to leave comments. Login now