Dear ipywidgets
gurus,
I want to set up a link between the attribute of some python object and the value of some ipywidget:
import ipywidgets as ipyw
w = ipyw.IntSlider(42)
class Foo(object):
def __init__(self, i=0):
self.i = i # not a traitlet, just an integer
foo = Foo(w.value)
two_way_link((w, 'value'), (foo, 'i')) # mimics ipyw.link()
foo.i = 5 # will move the slider of w
w.value = 8 # update foo.i
I thought of two_way_link
instantiating a wrapper traitlet around foo.i and then use ipyw.link
with this wrapper and w.value
. Maybe someone can suggest and alternative method?