How to animate elements?
Let's combine some of the things you've learned to create compelling animations in your app.
progress_bar = st.progress(0) status_text = st.empty() chart = st.line_chart(np.random.randn(10, 2)) for i in range(100): # Update progress bar. progress_bar.progress(i + 1) new_rows = np.random.randn(10, 2) # Update status text. status_text.text( 'The latest random number is: %s' % new_rows[-1, 1]) # Append data to the chart. chart.add_rows(new_rows) # Pretend we're doing some computation that takes time. time.sleep(0.1) status_text.text('Done!') st.balloons()
Still have questions?
Our forums are full of helpful information and Streamlit experts.