[IPython-dev] Link widget
Jason Grout
jason-sage at creativetrax.com
Thu Mar 13 14:18:08 EDT 2014
On 3/13/14, 12:59, Sylvain Corlay wrote:
> Quick question on the API:
>
> Does it really have to be a widget, or could it be a function in
> IPython.html.widgets.
>
> from IPython.html import widgets
> a = widgets.FloatSliderWidget(value=30)
> b = widgets.FloatSliderWidget()
>
> show(a)
> show(b)
>
> widgets.link([[a,'value'], [b,'value']]) # could be called "sync" as well
>
Somehow, the message has to get across to the javascript side that the
models should be linked together. We could send a message to, say, the
widget manager to do that, but right now we don't have a good way to
directly communicate with the widget manager and send it messages. I
hesitate to add such a messaging system when it seems even better to
have the link object be a separate object we can manipulate by itself.
By making the link a separate object (mirroring the link function in the
traitlets file), it's easy to change the properties of the link, or
abolish the link altogether. That said, we could make a link() function
in the widgets.py file that would construct, display, and return the
Link object.
I chose the name link because that was what we decided to do in the
traitlets case: https://github.com/ipython/ipython/pull/5060.
Thanks,
Jason
More information about the IPython-dev
mailing list