How to show the percentage number in st.progress bar?

now st.progress has a value to control the bar progress
how to display the value above bar when the value change

Hi @BeyondMyself ,
To display the value above the progress like the images bellow, you simply set a variable with st.empty() outside of your loop and assign the value of the progress bar inside your loop so that it gets updated as the bar progresses, like the following:

import streamlit as st
import time

latest_iteration = st.empty()
bar = st.progress(0)
num = 20
for i in range(num):
    latest_iteration.text(f'{num - i} seconds left')
    bar.progress((100//num)*i)
    time.sleep(1)

Let us know if this helped you solve your problem !

thanks for your solution, it works.
and I made some changes to apply in my example progroject for a job that needs 5 steps to finish:

# -*- coding: utf-8 -*-
import streamlit as st
import time

st.markdown(
    """
    <style>
        .stProgress > div > div > div > div {
            background-image: linear-gradient(to right, #99ff99 , #00ccff);
        }
    </style>""",
    unsafe_allow_html=True,
)

latest_iteration = st.empty()
bar = st.progress(0)

st.info("这里放第一步的要执行的代码,用1秒代替花费的时间")
time.sleep(1)
latest_iteration.text(f'还剩{4} 步就完成了')

bar.progress(20)

st.info("这里放第二步的要执行的代码,用1秒代替花费的时间")
time.sleep(1)
latest_iteration.text(f'还剩{3} 步就完成了')

bar.progress(40)


st.info("这里放第三步的要执行的代码,用1秒代替花费的时间")
time.sleep(1)
latest_iteration.text(f'还剩{2} 步就完成了')
bar.progress(60)


st.info("这里放第四步的要执行的代码,用1秒代替花费的时间")
time.sleep(1)
latest_iteration.text(f'还剩{1} 步就完成了')
bar.progress(80)


st.info("这里放第五步的要执行的代码,用1秒代替花费的时间")
time.sleep(1)
latest_iteration.text(f'全部完成了!')
bar.progress(100)

st.success("全部步骤执行完毕!")