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.

Changing variable with slider reloads page and resets all variables

See original GitHub issue

Summary

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:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
randyzwitchcommented, Sep 15, 2020

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

0reactions
ValerioFerreiracommented, Oct 11, 2022

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: @.***>

Read more comments on GitHub >

github_iconTop 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 >

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