How do I update the “options” of the selectbox dynamically?
Here is a mockup that I created. In the below mockup, I can only set the value for “options” only after I have fetched the data.
Here is a minimum non-working example
import streamlit as st
import time
def main():
st.session_state['choice'] = list(range(2))
st.selectbox("myoptions", options=st.session_state['choice'])
while True:
st.session_state['choice'] = list(range(5))
time.sleep(2)
@Charly_Wargnier: I see that you are a pretty active member of the community and a developer advocate. In that regards, can I ask if you have any suggestions?
import streamlit as st
import time
import random
def skeleton():
left, right = st.columns(2)
with right:
numbers = st.empty()
return left, right, numbers
left, right, numbers = skeleton()
while True:
with right:
with numbers.container():
st.selectbox('food',random.sample(range(10, 40), 4))
time.sleep(2)