[IPython-dev] Link widget
Jason Grout
jason-sage at creativetrax.com
Wed Mar 12 22:46:52 EDT 2014
Hi all,
I was working on the next level of optimizations for linking widgets
together, and came up with a Link widget that links widget values
together on the javascript side, to avoid a roundtrip to python. Demo here:
http://sagecell.sagemath.org/?q=bhlnao [1]
Notice that the first two sliders are lockstep with each other (they are
linked with the Link widget), but the third slider has a delay because
it necessitates a roundtrip to python.
Code is in my ipywidgets repository at
https://github.com/jasongrout/ipywidgets
The Link widget still has some things to fix (like unregistering if it
is destroyed or explicitly unbound, testing to make sure changing the
list of bindings has the right effect, etc.), but do you think it is
valuable enough of an idea to include in the standard widget set?
Thanks,
Jason
[1] Code at the link is:
html("<script
src='https://rawgithub.com/jasongrout/ipywidgets/master/widgets.js'></script>")
load('https://rawgithub.com/jasongrout/ipywidgets/master/widgets.py')
from IPython.html import widgets
a = widgets.FloatSliderWidget(value=30)
b = widgets.FloatSliderWidget()
c = widgets.FloatSliderWidget()
show(a)
show(b)
show(c)
javascript_link=Link(widgets=[[a,'value'], [b,'value']])
show(javascript_link)
from IPython.utils.traitlets import link
python_link = link([a,'value'], [c, 'value'])
print "Notice the delay in the third slider from the roundtrip to python."
More information about the IPython-dev
mailing list