0

enter image description here

Is there any way to show the time menu like above on streamlit? This menu should show every single hour and minute. Other hand streamlit time input provides only pre defined time arrivals like 08:00 08:15 08:30 08:45 etc. I don't want this. How can I solve this problem?

murat taşçı
  • 64
  • 1
  • 2
  • 22

2 Answers2

0
  start = "00:00"
    end = "23:59"
    times = []
    start = now = datetime.datetime.strptime(start, "%H:%M")
    end = datetime.datetime.strptime(end, "%H:%M")
    while now != end:
        times.append(str(now.strftime("%H:%M")))
        now += datetime.timedelta(minutes=1)
    times.append(end.strftime("%H:%M"))
    st.multiselect('Departure hour:',times)
murat taşçı
  • 64
  • 1
  • 2
  • 22
0

Improved answer:

times = []
for hours in range(0, 23):
  for minutes in range(0, 59):
    times.append(datetime.time(hours, minutes))
st.selectbox("Time", times, key="time", format_func=lambda t: t.strftime("%H:%M"))
Martin Thøgersen
  • 1,538
  • 18
  • 33