Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG(?): Player doesn't play if displaying twice #3967

Open
hai-schrodinger opened this issue Nov 25, 2024 · 1 comment
Open

BUG(?): Player doesn't play if displaying twice #3967

hai-schrodinger opened this issue Nov 25, 2024 · 1 comment

Comments

@hai-schrodinger
Copy link

hai-schrodinger commented Nov 25, 2024

Hi there,

image

Please try above. If display once, the player will play and the slider value keeps changing. If displaying twice and clicking the play button, the slider value only changes once.

@hai-schrodinger hai-schrodinger changed the title Player doesn't play if displaying twice BUG(?): Player doesn't play if displaying twice Nov 25, 2024
@afonit
Copy link

afonit commented Dec 3, 2024

Putting your code here so others can reproduce more quickly - I can confirm the behavior you are seeing.

from ipywidgets import IntSlider, Play
from traitlets import link

player = Play()
slider = IntSlider(max=10, min=0, step=1)
link((player, 'value'), (slider, 'value'))
slider

the behavior also occurs when using observe (not sure if that does the exact same thing as the link you used)

from ipywidgets import IntSlider, Play, HBox
from traitlets import link

player = Play(interval=500)
slider = IntSlider(max=100, min=0, step=1)
# link((player, 'value'), (slider, 'value'))

def on_value_change(change):
    slider.value = change['new']
    # print(change['new'])
    

player.observe(on_value_change, names='value')

# uncomment the below line to see the working model
# HBox([slider, player])

# uncomment the below line to see that when you hit play it only increments once for each time play is clicked
# HBox([slider, player, player])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants