diff --git a/docs/source/examples/Widget Events.ipynb b/docs/source/examples/Widget Events.ipynb index ad12de1b64..1e06ce5410 100644 --- a/docs/source/examples/Widget Events.ipynb +++ b/docs/source/examples/Widget Events.ipynb @@ -250,18 +250,7 @@ "source": [ "### Linking traitlets attributes in the kernel\n", "\n", - "The first method is to use the `link` and `dlink` functions from the `traitlets` module. This only works if we are interacting with a live kernel." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import traitlets" + "The first method is to use the `link` and `dlink` functions from the `traitlets` module (these two functions are re-exported by the `ipywidgets` module for convenience). This only works if we are interacting with a live kernel." ] }, { @@ -316,7 +305,7 @@ "caption = widgets.Label(value='The values of slider1 and slider2 are synchronized')\n", "sliders1, slider2 = widgets.IntSlider(description='Slider 1'),\\\n", " widgets.IntSlider(description='Slider 2')\n", - "l = traitlets.link((sliders1, 'value'), (slider2, 'value'))\n", + "l = widgets.link((sliders1, 'value'), (slider2, 'value'))\n", "display(caption, sliders1, slider2)" ] }, @@ -372,7 +361,7 @@ "caption = widgets.Label(value='Changes in source values are reflected in target1')\n", "source, target1 = widgets.IntSlider(description='Source'),\\\n", " widgets.IntSlider(description='Target 1')\n", - "dl = traitlets.dlink((source, 'value'), (target1, 'value'))\n", + "dl = widgets.dlink((source, 'value'), (target1, 'value'))\n", "display(caption, source, target1)" ] }, @@ -651,15 +640,14 @@ } ], "source": [ - "import traitlets\n", "a = widgets.IntSlider(description=\"Delayed\", continuous_update=False)\n", "b = widgets.IntText(description=\"Delayed\", continuous_update=False)\n", "c = widgets.IntSlider(description=\"Continuous\", continuous_update=True)\n", "d = widgets.IntText(description=\"Continuous\", continuous_update=True)\n", "\n", - "traitlets.link((a, 'value'), (b, 'value'))\n", - "traitlets.link((a, 'value'), (c, 'value'))\n", - "traitlets.link((a, 'value'), (d, 'value'))\n", + "widgets.link((a, 'value'), (b, 'value'))\n", + "widgets.link((a, 'value'), (c, 'value'))\n", + "widgets.link((a, 'value'), (d, 'value'))\n", "widgets.VBox([a,b,c,d])" ] }, diff --git a/ipywidgets/__init__.py b/ipywidgets/__init__.py index 56ddbf896f..09da954638 100644 --- a/ipywidgets/__init__.py +++ b/ipywidgets/__init__.py @@ -23,6 +23,7 @@ from IPython import get_ipython from ._version import version_info, __version__, __protocol_version__, __jupyter_widgets_controls_version__, __jupyter_widgets_base_version__ from .widgets import * +from traitlets import link, dlink def load_ipython_extension(ip):