ipywidget play bug ?

24 views
Skip to first unread message

oscar6echo

unread,
Jul 1, 2017, 6:59:11 PM7/1/17
to Project Jupyter
Most likely I just could not make it work...

In the code below the player does not seem to catch any event so does not run on_change2.
Whether I use traitlets.link or widgets.jslink does not change the behavior.
But the player is properly linked to the slider as the output print shows.
What am I missing ?...

I'm trying to make a standard slider+player command à la Mathematica (like here)

Thx

Jupyter In cell:
import traitlets
import ipywidgets as widgets

mi
, ma, s, v = 1, 100, 2, 5
i
= 500
player
= widgets.Play(min=mi, max=ma, step=s, value=v, interval=i)
slider
= widgets.FloatSlider(min=mi, max=ma, step=s, value=v)
# traitlets.link((player, 'value'), (slider, 'value'))
widgets
.jslink((player, 'value'), (slider, 'value'))

w
= widgets.HBox([slider, player])

def on_change1(change):
print('1', change, player.value)

def on_change2(change):
print('2', change, slider.value)

slider
.observe(on_change1, 'value')
player
.observe(on_change2, 'value')

w


Out cell:
1 {'name': 'value', 'old': 5.0, 'new': 7.0, 'owner': <ipywidgets.widgets.widget_float.FloatSlider object at 0x1196c4278>, 'type': 'change'} 7 1 {'name': 'value', 'old': 7.0, 'new': 9.0, 'owner': <ipywidgets.widgets.widget_float.FloatSlider object at 0x1196c4278>, 'type': 'change'} 9 1 {'name': 'value', 'old': 9.0, 'new': 11.0, 'owner': <ipywidgets.widgets.widget_float.FloatSlider object at 0x1196c4278>, 'type': 'change'} 11


My config:

Olivier@Central:~ (3) $ conda list ipyw
# packages in environment at /Users/Olivier/anaconda3:
#
ipywidgets
6.0.0 py36_0 conda-forge


Reply all
Reply to author
Forward
0 new messages