Home > Back-end >  How to make N checkboxes in streamlit?
How to make N checkboxes in streamlit?

Time:02-24

I want to make a remainder app, kind that user can infinity many times make checkboxes. for example:

  1. do hw
  2. read this article ...

it is basically a to do list.

'''

import streamlit as st
hw = []
todo =st.text_input("Input To do list elements here")


while todo != "done":
    hw.append(todo)
    todo = st.text_input("Input To do list elements here")

for i in hw:
    checkbox=st.checkbox(i)

'''

this is the code I am trying to use, I know this won't get me there, but I am for now just want to be able to make checkboxes and check them in streamlit but cannot solve the error message which says that I cannot use same key for multiple st.text_input or other error of running loop infinity many times even tho I input the break statement "done".

Maybe there is a different solution, I want to hear it all.

CodePudding user response:

It looks like you think that st.text_input("Input To do list elements here") will ask for input immediately from the user. However, that's not how it works. Instead text_input() creates a text widget that you can place inside of a web page for a user to type into. The actual input will not be returned immediately.

I suggest that you read enter image description here

  • Related