Interface of streamlit

I have a dataset having 50 dealers. Now I used check box to select them. But in my Streamlit interface all 50 names are shown and it looked very clumsy. Can anyone guide me how to modify that interface so that it is very eye catching?

can you share your code here?

def multiple_checkbox(data1, select_column_name, value1,value2):
    data = data1
    data[select_column_name] = data[select_column_name].astype(str)
    unique = data[select_column_name].values.tolist()
    myset = set(unique)
    mynewlist = list(myset)   
    dummy_data = mynewlist    
    st.session_state['dummy_data'] = dummy_data

        def checkbox_container(data2, val1, val2):
            col = st.columns(4)
            if col[2].button('All', key = val1):
                for i in data2:
                    st.session_state['dynamic_checkbox_'  + i] = True
                st.experimental_rerun()
            if col[3].button('None', key = val2):
                for i in data2:
                    st.session_state['dynamic_checkbox_'  + i] = False
                st.experimental_rerun()
            for i in data2:
                st.checkbox(i, key= 'dynamic_checkbox_' + i)

        def get_selected_checkboxes():
            return [i.replace('dynamic_checkbox_' ,'') for i in st.session_state.keys() if i.startswith('dynamic_checkbox_') and st.session_state[i]]


        checkbox_container(dummy_data, value1, value2)
        data = data[data[select_column_name].isin(get_selected_checkboxes())]
        return(data)

I am using the same code maultiple time so I think to define it as a function. Also I add β€œAll” and β€œNone” button in the code.

st.multiselect is usually the function for something like this, so that you don’t need 50 instances of a widget:

Best,
Randy


Can I do the similar thing using st.multiselect? If not then I need a tool in streamlit which can create the similar thing which is shown in the picture. Please help me @randyzwitch & @BeyondMyself .

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.