Play widget won't call the function
See original GitHub issueI am using Jupyter notebook and trying to make its Play widget work. As a start, I want to create a slider that would automatically roll over its range and execute the connected function. Consider the following code:
import ipywidgets as widgets
def on_value_change(change):
print(change['new'])
slider = widgets.IntSlider(min=1, max=100, step=1, continuous_update=True)
play = widgets.Play(min=1, interval=2000)
slider.observe(on_value_change, 'value')
widgets.jslink((play, 'value'), (slider, 'value'))
widgets.VBox([play, slider])
As expected, whenever I click back and forth on the slider, the function on_value_change
is called and the current value is printed on the output. However, when I launch the animation via the play button, nothing is printed. In fact, it looks like on_value_change
is not even called. Could anyone please explain the reason? Is it a bug?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Can't call character functions in widget - Unreal Engine Forums
Hello, I'm creating a widget that calls a function from the character. It should display another widget with custom properties.
Read more >Flutter: Call a function on a child widget's state - Stack Overflow
When I press the play button, my main class needs to call play() on the state's VideoPlayerController, so I created a function inside...
Read more >Can't call a function from a widget. : r/unrealengine - Reddit
Hello, I am having problems calling a function from a widget (Have been following this series https://www.youtube.com/watch?v=QGIie_bDmeQ&list= ...
Read more >Call function from another widget in [FLUTTER] - YouTube
MEDIUM:https://medium.com/@thefujii/how-to- call -a- function -from-another- widget -flutter-tutorial-283dfc431554JOIN OUR ...
Read more >Music widget permanently on lock screen? - Apple Developer
Can't seem to figure out how to get rid of the music player on the lock screen ... call by replying to what...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This has to do with telling the system where output should go. For example, this works because we explicitly capture the output into an output widget:
And technically, I think what is happening is this:
Point 3 may be clearer if you have the display the play widget in one cell, and slider twice in two different cells. Where should output go? In the output associated with the play widget, where the user actually interacted with a control? Or in the first or second displayed slider cells, where the slider is actually moving?
That’s why explicitly capturing the output and displaying it where ever you want works better in general.