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 
<http://reference.wolfram.com/language/tutorial/IntroductionToManipulate.html.en>
)

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


-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/db16fd7b-eaf7-42cf-8ac1-bfa068e79b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to