I want to display a status widget that gets its value from some external server (say, WebSocket).
I wouldnât want to rerun the streamlit app to update the status widget, rather Iâd want it to update itself every second on its own (possibly on the frontend).
Ideally, the component would look âorganicâ, in the sense that it would respect the current theme set in streamlit.
Whatâs the easiest way of achieving that?
You can make use of the time
module (namely the sleep
method to add a delay) when iterating through time. Make sure to first define a placeholder with st.empty()
and for each iteration you can display an update of the component of interest by assigning it to the placeholder.
Please see this blog (How to build a real-time live dashboard with Streamlit) particularly section 5 in order to see this in action.
Hope this helps!