When a widget is created on the page ie st.checkbox(âmycheckboxâ) itâs very easy to base actions on the state of the object when it is clicked on etc. But if I have a loop that creates several checkboxes in a list, for example, that are just hanging out waiting to be clicked on, itâs not clear how the individual checkboxes are identified in functions. Example code:
//create the named checkboxesâŚ
for name in namelist:
st.checkbox(name)
If there are 10 items in ânamelistâ streamlit will present 10 checkboxes. If I also have a button on the screen that calls a function to return a list containing the names of the checkboxes that have been checked. I donât see how I can check the value of each checkbox with out having a object reference for each one. I tried this:
def getCheckBoxValue(cbname)
return st.checkbox(cbname)
somehow this seems to recreate another checkbox when the function is called and then there is an error because the new checkbox will be a duplicate of the one previously made with that name.
The goal is to simply get a list of names cooresponding to the checkkboxes that are checked when a button is pressed.
Iâm missing some very fundamental concept. Any help would be greatly appreciated.
Thanks.