Open chraibi opened 7 months ago
try:
highlight_times = [float(time.strip()) for time in user_input.split(',') if time.strip().isdigit()]
except ValueError:
st.error("Please enter valid times (numbers only, separated by commas).")
highlight_times = []
# Session state to keep track of the times list
if 'highlight_times' not in st.session_state:
st.session_state.highlight_times = []
# Text input for new time addition
new_time = st.text_input("Enter a new time to highlight (seconds):")
# Button to add the new time to the list
if st.button('Add Time'):
try:
# Attempt to convert the input to a float and add it to the list
time_float = float(new_time.strip())
if time_float not in st.session_state.highlight_times:
st.session_state.highlight_times.append(time_float)
st.session_state.highlight_times.sort() # Keep the list sorted
except ValueError:
st.error("Please enter a valid time (a number).")
# Multiselect box for displaying and removing times
selected_times = st.multiselect("Selected times (unselect to remove):",
options=st.session_state.highlight_times,
default=st.session_state.highlight_times)
# Update the highlight times based on multiselect
st.session_state.highlight_times = selected_times
Add the possibility to add flexible numbers of dots on the time series.