Skip to content

Commit

Permalink
Merge pull request #1923 from rprimet/link_export
Browse files Browse the repository at this point in the history
re-export link and dlink from traitlets for consistency with the javascript api
  • Loading branch information
jasongrout authored Jan 25, 2018
2 parents e218cd9 + 3ca8108 commit 648dd00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
24 changes: 6 additions & 18 deletions docs/source/examples/Widget Events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand Down Expand Up @@ -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)"
]
},
Expand Down Expand Up @@ -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)"
]
},
Expand Down Expand Up @@ -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])"
]
},
Expand Down
1 change: 1 addition & 0 deletions ipywidgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 648dd00

Please sign in to comment.