Option return different than labels

Hey guys,

In an option = st.selectbox(labels) is there a way to have the option that is being returned being different than the labels being shown? (but still 1:1)? I would like to show a more human readable option on the UI, but have a compact name returned in python.

Thanks!

Hi @ValdiMeti,

Use the format_func option to complete this. Here is a bit more information: https://github.com/streamlit/streamlit/blob/455ae6190a09933f9d9ccd625ef64aa31c3f6a75/lib/streamlit/DeltaGenerator.py#L1386.

-Adrien

Nice! This is exactly what I needed. Thanks again.

1 Like

The link is dead for me. Can you post another link, please? Would like to know how to re-label my option labels. Thanks in advance!

No problem

Example: https://github.com/streamlit/streamlit/blob/develop/e2e/scripts/selectbox.py#L22
Docs: https://streamlit.io/docs/api.html#streamlit.selectbox

1 Like

@pybokeh: Sorry about that. I fixed the link now: https://github.com/streamlit/streamlit/blob/455ae6190a09933f9d9ccd625ef64aa31c3f6a75/lib/streamlit/DeltaGenerator.py#L1386