Changing variable with slider reloads page and resets all variables
See original GitHub issueSummary
When clicking on a slider to change its value, the app gets reloaded and all variables are changed to their default values.
Steps to reproduce
I have an app with several parameters, set using a variety of Streamlit widgets. I try to change the value of one of the variables (a slider) by clicking on a point along the slider. Here is the slider code:
temp = st.slider("Temperature (F)",
min_value=30,
max_value=100,
value=70,
step=1)
Expected behavior:
I expect the variable to change and the app to run with the value that is selected.
Actual behavior:
The app reloads in the browser and all variables (including the slider on which I selected the value) are reverted to their default values.
Debug info
- Streamlit version: 0.66.0
- Python version: 3. I 8.5
- Using Conda: yes
- OS version: macOS Catalina
- Browser version: Chrome 85
Additional information
If needed, add any other context about the problem here. For example, did this bug come from https://discuss.streamlit.io or another site? Link the original source here!
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Global Variable Keeps Changing - Power Platform Community
Solved: I use a global variable as a size multiplier for most of my controls. On each screen is a slider (scale of...
Read more >Variable Resets to 0 every refresh - javascript - Stack Overflow
It is because every time you refresh your page, your code reinitializes. In-order to persist the data, you need to store it somewhere....
Read more >Avoid rerunning for intermediate values for number_input ...
Run only when all the variables' values in number_inputs are finalized using +/- sign. Solution: I have put one checkbox(condition-yes/no) so ...
Read more >Slider changes progressbar length and reloads gui - AutoHotkey
I'm trying to create Slider which changes progressBar length (range) -> restarts GUI -> and to have progressbar with new parameter from ...
Read more >variables, resume, and retain variables in published for web
However, on a revisit or reload, the variables are all reset to ... The lightboxed slide triggers the retention of the variable change...
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 FreeTop 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
Top GitHub Comments
Hi @fonnesbeck -
Can you provide more of a code example for us to evaluate? Something that demonstrates the behavior you think is incorrect.
Best, Randy
I appreciate the feedback! I’ll be reading it right now!
Enviado do Emailhttps://go.microsoft.com/fwlink/?LinkId=550986 para Windows
De: Randy @.> Enviado:segunda-feira, 6 de junho de 2022 17:57 Para: @.> Cc:Valério @.>; @.> Assunto: Re: [streamlit/streamlit] Changing variable with slider reloads page and resets all variables (#1996)
The Streamlit execution model is that the code always runs top-to-bottom. It does not differentiate that the slider is downstream of the other code in a DAG-like manner.
If you want to avoid having expensive processes run each time, please see the documentation which refers to caching within Streamlithttps://docs.streamlit.io/library/advanced-features/experimental-cache-primitives.
Best, Randy
— Reply to this email directly, view it on GitHubhttps://github.com/streamlit/streamlit/issues/1996#issuecomment-1147920322, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWFIL565AGPVEO22BX2EITLVNZQ2HANCNFSM4RL763FQ. You are receiving this because you commented.Message ID: @.***>