Extracting selected st.column_config.CheckboxColumn

code from st.column_config.checkboxcolumn, is there anyway to st.write out the selected item?

Thank you so much

import pandas as pd
import streamlit as st

data_df = pd.DataFrame(
    {
        "widgets": ["st.selectbox", "st.number_input", "st.text_area", "st.button"],
        "favorite": [True, False, False, True],
    }
)

st.data_editor(
    data_df,
    column_config={
        "favorite": st.column_config.CheckboxColumn(
            "Your favorite?",
            help="Select your **favorite** widgets",
            default=False,
        )
    },
    disabled=["widgets"],
    hide_index=True,
)

Hello @Hien_P .

You can assign the st.data_editor to a variable, and then access the column β€œfavorite” from it (the column that you have set the st.column_config.CheckboxColumn). The code below produces the following result:

import pandas as pd
import streamlit as st

data_df = pd.DataFrame(
    {
        "widgets": ["st.selectbox", "st.number_input", "st.text_area", "st.button"],
        "favorite": [True, False, False, True],
    }
)

test = st.data_editor(
    data_df,
    column_config={
        "favorite": st.column_config.CheckboxColumn(
            "Your favorite?",
            help="Select your **favorite** widgets",
            default=False,
        )
    },
    disabled=["widgets"],
    hide_index=True,
)

st.text(test)
st.text(test['favorite'])

Hope this helps!

1 Like

Awesome!!! Thank you so much for your help

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