I am not sure if this is a bug but the following code behaves very strange to me:
import streamlit as st time = st.time_input('input the time', key='time') st.text(time)
When I load the page for the first time, the default value of the
time_input widget will be current system time, say for example
10:00, and I am able to change the value with no problem.
However after 1 minute (i.e. when system clock shows
10:01), when I try to change to the widget value again, no matter what value I selected, the value will turn into
It seems like
time_input widget is forced to reset to current time every minute. And during each minute, it can be freely changed.
The only workaround I can find is to set both
import datetime as dt import streamlit as st if 'time' not in st.session_state: st.session_state['time'] = dt.datetime.now().time() time = st.time_input('input the time', value=st.session_state['time'], key='time') st.text(time)
However this will raise the warning
The widget with key "time" was created with a default value but also had its value set via the Session State API.