I expect the app to rerun as soon as a state variable is changed. But that is not happening.
update_state("NAME", value)
This doesn’t rerun the app. The app only reruns after I interact with some widget and then the changes are visible according to the new state value.
Currently, I’m manually rerunning which works fine:
In Streamlit, updating a session state variable does not trigger a rerun.
What you are doing is correct (i.e. explicitly triggering a rerun), but if I can suggest an alternative, look into callback functions in widgets. That way you can update the state before the app rerun that is triggered whenever a user interacts with a widget.
Thanks for quick reply @marduk . Glad you like it
So you mean something like - st.button(..., on_click=update_state) ?
that seems nice! but can’t really pass the arguments to the function signature, so I was using:
button = st.button(...)
if button:
update_state
So what’s the usual workflow in this case. There’s an update function for each widget hardcoded to that state variable?
@marduk If I may, I have one off topic question about streamlit.
So after looking at many apps, I’ve finally settled to streamlit because of multiple reasons. I’m not building my own backend+frontend because I want to iterate quickly. But I also I want to make this app usable(hosted locally by each user so nothing production heavy [for now]). The app will be data heavy(load 1000s of images in browser, even more) and the performance is key.
Up until now my experience has been seamless. There was one plugin that I had to redo a bit but other than that, I’m pretty impressed.
Now, my question is - is streamlit intended to be used for such applications? Or should I think if this as stretching a prototyping tool? I read some articles saying streamlit doesn’t have the best performance so it’s only good for prototyping. While it might be true, I have not had any major performance issues as I expand tabs and pages so I’m thinking to double down on it.
So, it’d be great if I could get a response from the team about a few things:
Where does supporting large data apps like this rank in the priority list?
I’m happy to invest more time in streamlit and I also want to know if roadmap is to evolve the tool and its image from rapid protyping solution to no-code web solution for python. (See anvil)
Happy to hop on a call with the team to talk about by use cases in detail. I rarely come across tools that work exactly as expected. Very impressive work
EDIT: I assumed you are from streamlit team. If not, please put me in touch with the right person if you know them
Not part of Streamlit, but some thoughts in case useful:
You can keep track of upcoming features and performance improvements in the GitHub repo or the Streamlit roadmap.
No UI framework is perfect. Evaluate any choice in terms of:
Rendering performance (is the UI you want rendering quickly enough?)
Resource usage (are there any memory leaks?)
Configurability (can you create new widgets and styles?)
Security
Support
Iteration speed
In my opinion your app is a good use case for Streamlit because it is Python based, for internal use and run locally by each user (not deployed online, so you don’t have to worry as much about things like security), and you want to iterate quickly.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.