St.radio placeholder

Hi all,
my code for the st.radio looks like this:

st.session_state['pdf_rendering'] = st.radio(
        "PDF rendering mode",
        ("Streamlit PDF Viewer (Pdf.js)", "Legacy PDF Viewer"),
        index=0,
        disabled=not uploaded_file,
        help="PDF rendering engine."
             "Note: The Legacy PDF viewer does not support annotations and might not work on Chrome."
    )

after I have to do something like

if st.session_state['pdf_rendering'] == "Streamlit PDF Viewer (Pdf.js)": 
    blabla 
else: 
    something else 

I was wondering if I could assign some fixed placeholder to each radio value. So that when changing the radio text I don’t have to update the code somewhere else.

Use the format_func parameter to st.radio to change the displayed text without affecting the value.

1 Like

Thanks! That worked!

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