Display several pieces of strings incrementally on the same line

Hi @Justin1904 -

This is a hilarious hack from @Jonathan_Rhone that shows how to make a scrolling ticker, maybe this will get you close to what you want to do:

import time
import streamlit as st

text = "Welcome to the first day... of the rest... of your life"


t = st.empty()
for i in range(len(text) + 1):
    t.markdown("## %s..." % text[0:i])
    time.sleep(0.1)

It uses st.empty() to make a placeholder, then writes to the placeholder based on the data. You could imagine in your scenario, writing the words to a list, then slicing the list to show the words you want to see.

3 Likes