Streamlit show streamlit suboptions under selected option

52 views Asked by At

I have a streamlitradio for an expertsystem. With the options selected a number is created. Depending on the selected option, there are different suboptions, which makes up the number. There are different number of sub options depending on the type.

This is currently implemented with streamlit in python and the other suboptions are displayed at the end of the list of parent options. I would now like to have it so that after the user clicks on an option, the sub-options become visible directly below it. The unselected options should still be visible to be able to correct them if necessary.

Unfortunately I have not found a solution online. Can someone please help me?

1

There are 1 answers

0
Matthias Mertens On

Would something like that work?

import streamlit as st

changed = false
def onchange():
    changed = true

category = st.radio(
    "some label",
    [1,2,3,4,5],
    on_change=onchange
)

if changed:
    if category == 1:
        st.radio(
            ...
    if category == 2:
        ...