Time_input widget resets itself

Greetings!
I am Using two st.time_input widgets to select a timewindow.
The values are given via st.sessionstate.
It works fine if I constantly use it, but if I wait for about a minute and then adjust the timewindow both widgets reset to the current time.
The Date_input doesnt seem affected.
Does onyone know why this happends and how to handle it?
here is my code

if 'Datum von' not in st.session_state:
    st.session_state['Datum von'] = datetime.today() - timedelta(days=1)
if 'Datum bis' not in st.session_state:
    st.session_state['Datum bis'] = datetime.today()
if 'Uhrzeit von' not in st.session_state:
    st.session_state['Uhrzeit von'] = datetime.now().time()
if 'Uhrzeit bis' not in st.session_state:
    st.session_state['Uhrzeit bis'] = datetime.now().time()

col1, col2 = st.columns(2)#auswahl des zeitfensters der angezeigten daten
with col1:
    date1 = st.date_input("Von", key = 'Datum von')
    time1 = st.time_input("Uhrzeit",  key = 'Uhrzeit von')
    dt1 = datetime.combine(date1, time1)
with col2:
    date2 = st.date_input("Bis", key = 'Datum bis')
    time2 = st.time_input("Uhrzeit", key = 'Uhrzeit bis')
    dt2 = datetime.combine(date2, time2)

Regards Leo

1 Like

I just replace the time_input with sliders, now the problem is gone.
Does someone know why?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.