Disabling continuous update when interacting with slider

Hello everyone !

After trying Streamlit for building a quick prototype to present some analytics results internally, I decided to spend more time with the library :slight_smile:

A year ago I built a little interactive regression using ipywidgets inside a Jupyter notebook. The goal was to show in a ML introductory talk how we could manually search for the best parameters to fit a function/decision tree/etc… to data.

I thought this would be a good app to port to Streamlit, so I quickly made a first draft with sliders in the sidebar updating the Altair chart for the function with selected parameters, so far so good !

then realized that unlike ipywidgets, we can’t restrict updating the execution to mouse release events, at least at first glance of the API reference.

I think the pros & cons for continuous update are well documented in the ipywidgets disabling continuous update doc, so I think it could be interesting to provide the user with the choice between continuous update, no update and have another button rerun the script, and restrict execution to mouse release events.

It is something in the works, or maybe others have encountered this and found other solutions ?

2 Likes

Hi @andfanilo.

Welcome to the community.

Streamlit is great in many ways but your example is something where I think it could be improved. Due to Streamlits execution model the whole script is rerun whenever the user changes the value of a widget. And that update is not as fast as what you get from Panel or Voila.

You can add a “pause” checkbox to your application and only run your code if the checkbox is not checked.

There are some issues related to your problem on Github. One is https://github.com/streamlit/streamlit/issues/166#issuecomment-540615056 and another is https://github.com/streamlit/streamlit/issues/494.

It would be helpfull if you added your needs, comments and ideas to the Github issues. Thanks.

2 Likes

Another related issue is Add API ability to trigger execution of a function only upon use of widget. · Issue #711 · streamlit/streamlit · GitHub

If you feel these issues don’t accurately or comprehensively describe your desired behavior of

provide the user with the choice between continuous update, no update and have another button rerun the script, and restrict execution to mouse release events.

then feel free to open a new issue @andfanilo

Hey, thank you for your inputs !

I read your issues and related issues, and have compilted my thoughts in a new issue.

It seems like the no update and have another button rerun the script has been discussed a lot already, and I figured a quick snippet that could work, but the restrict execution to mouse release events is not as visible so I figure I’d give it a go.

I’ll try to spin a VM and compile the source code now so I can try to edit the React part and see what happens :slight_smile: .

2 Likes

Awesome @andfanilo . Looking forward to hear how it goes.

Oh, this has a solution now:

4 Likes

This is awesome.

I hope that in the future it become a standard feature in Streamlit

4 Likes