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

AnimationOptions for sliders #1824

Closed
PatrickCode365 opened this issue Jan 19, 2025 · 2 comments
Closed

AnimationOptions for sliders #1824

PatrickCode365 opened this issue Jan 19, 2025 · 2 comments

Comments

@PatrickCode365
Copy link

In Shiny for R they can use AnimationOptions() to control their animation for the slider ui , I'm currently using shiny for python and am trying to control the animation for my slider but i cannot seem to find any resource for python using AnimationOptions even in https://shiny.posit.co/py/api/core/ui.input_slider.html under animation they say you can use it but it doesn't seem to work , was this feature not added to shiny for python? or am i doing something wrong. I would like to speed the slider up as the step being small makes the animation take longer but id like to make the step small and the animating faster

@cpsievert
Copy link
Collaborator

cpsievert commented Jan 21, 2025

Animation options are supported py-shiny, but unfortunately, it's currently not very clear how to do so since the AnimationOptions type currently isn't exported. That said, the type looks like this:

class AnimationOptions(TypedDict):
    interval: NotRequired[int]
    loop: NotRequired[bool]
    play_button: NotRequired[TagChild]
    pause_button: NotRequired[TagChild]

which means you can customize the options like this:

ui.input_slider("obs", "Number of bins:", min=10, max=100, value=30, animate={"interval": 10})

@PatrickCode365
Copy link
Author

Thank you , this helps a lot.

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

No branches or pull requests

2 participants