I am new to Streamlit so forgive me if I am missing something obvious.
I have created an app that reads in a list of items and uses a loop to display each one next to a radio widget in a single form. The user then makes selections for the radio buttons (think “buy”/ “sell”/“hold”) and submits the form. I want to capture each widget’s state at form submission, but I am trying to figure out a way to identify which widget is which. I can give them each a unique “key” but I don’t know how to use this to access the state at submission time.
Here is a minimal example:
import streamlit as st
stocks = # some arbitrary-length list of stock symbols
with st.form("stock_picker"):
for stock_symbol in stocks:
col1, col2 = st.beta_columns(2)
with col1:
decision = st.radio("Decision", ["Buy", "Sell", "Hold"], key=stock_symbol)
with col2:
st.write(stock_symbol)
submitted = st.form_submit_button("Submit")
if submitted:
# How to capture each `decision` here?