question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to change ipywidget animation speed during animation

See original GitHub issue

I am using jupyter notebook to animate a marker that moves along an ant path. I am using ipyleaflet and ipywidgets. I have added a slider widget (speed_slider) to my map, to allow me change the speed of the animation. My animation is using a for loop code as shown in below code.

for i in ant_path.locations:
    mark.location = i
    sleep(speed_slider.value)

I am able to set the animation speed before running the cell that contains the above for loop code, but I am not able to change the speed during animation. Please any suggestions on how change the animation speed during the animation runtime, using the slider.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Oao2021commented, Sep 7, 2021

Thanks so much Martin. Implemented and working perfectly.

0reactions
martinRenoucommented, Sep 7, 2021

Something like the last cell of this Notebook: https://github.com/martinRenou/ipycanvas/blob/master/examples/conways_game_of_life.ipynb

So something like:

from threading import Thread

class AntPathAnimation(Thread):
    def __init__(self, ant_path, mark, speed_slider):
        self.ant_path = ant_path
        self.mark = mark
        self.speed_slider = speed_slider
        super(AntPathAnimation, self).__init__()

    def run(self):
        for i in self.ant_path.locations:
            self.mark.location = i
            sleep(self.speed_slider.value)

AntPathAnimation(ant_path, mark, speed_slider).start()
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change ipywidget animation speed during animation
I am using ipyleaflet and ipywidgets. I have added a slider widget (speed_slider) to my map, to allow me change the speed of...
Read more >
[UMG] Change widget animation duration? : r/unrealengine
The user picks a duration from a list (there are about 7 options in total), and the image animation plays for that many...
Read more >
Animations - Axure Docs
You can animate certain actions to give them a visual effect as they occur in the web browser, such as hiding a widget...
Read more >
AnimatedPositioned class - widgets library - Dart API
For the animation, you can choose a curve as well as a duration and the widget will automatically animate to the new target...
Read more >
Animated Image Widget - VTScada
When used for tags that have analog values, the speed of the animation reflects the value of the tag. For tags with simple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found