Created
April 19, 2022 14:27
-
-
Save asehmi/543b056c162317074a35ce22677a316f to your computer and use it in GitHub Desktop.
Standard Streamlit progress bar demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import time | |
import numpy as np | |
progress_bar = st.sidebar.progress(0) | |
status_text = st.sidebar.empty() | |
last_rows = np.random.randn(1, 1) | |
chart = st.line_chart(last_rows) | |
for i in range(1, 101): | |
new_rows = last_rows[-1, :] + np.random.randn(5, 1).cumsum(axis=0) | |
status_text.text("%i%% Complete" % i) | |
chart.add_rows(new_rows) | |
progress_bar.progress(i) | |
last_rows = new_rows | |
time.sleep(0.05) | |
progress_bar.empty() | |
# Streamlit widgets automatically run the script from top to bottom. Since | |
# this button is not connected to any other logic, it just causes a plain | |
# rerun. | |
st.button("Re-run") |
Author
asehmi
commented
Apr 19, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment