I have a multiselectbox in the sidebar of my streamlit app. Without loss of generality:
- I have 10 options to put in this multiselectbox (these are the numbers 1...10)
- The user may not select both
1and2simultaneously
I would therefore like to remove 2 from the list of possible selections if 1 is selected, but streamlit seems to have no capability for this, so I tried to wrap it in a loop, which also fails (DuplicateWidgetID: There are multiple identical st.multiselect widgets with the same generated key.):
options = [1,2,3,4,5,6,7,8,9,10]
space = st.sidebar.empty()
answer, _answer = [], None
while True:
if answer != _answer:
answer.append(space.multiselectbox("Pick a number",
options,
default=answer
)
)
options = [o for o in options if o not in answer]
if 1 in options:
if 2 in options: options.remove(2)
if 2 in options:
if 1 in options: options.remove(1)
_answer = answer[:]
Any thoughts on how I could achieve this?


