I'm trying to add columns to the expander, but unfortunately it doesn't seem to take effect


I’m trying to add columns to the expander, but unfortunately it doesn’t seem to take effect

Steps to reproduce

Code snippet:

            expanderList.append(st.expander('💡 Generate Results %s'%lineNum, expanded=False))
            columns = expanderList[lineNum].columns([1] * MODEL_CONFIG['rank_list_len'])
            for i, c in enumerate(columns):
                with c:
                    choice = expanderList[lineNum].selectbox(f'i+1', rank_choices,key=tagNum,
                    if choice != -1 and choice in rank_results:
                        rank_results[i] = choice
                    texts[i] = expanderList[lineNum].text_area('answer%s:'%tagNum,texts[i],height=200)
                tagNum = tagNum + 1
                index = index + 1

Expected behavior:Add several columns to the expander

Actual behavior:Unable to recognize column, still changed layout to row

Debug info

  • Streamlit version: 1.17.0
  • Python version: 3.8.15
  • Using Conda
  • OS version: WIN11
  • Browser version: Chrome 109.0.5414.120x64

Requirements file

No special dependency library


  • Link to your GitHub repo:None
  • Link to your deployed app:None

Additional information


Without carefully parsing your code to see if there is something else going on, the thing that jumps out at me is:

You are trying to write in a column while simultaneously specifying you are not writing in the column. If you want to use with c: then inside should be st.selectbox. Not <some other location not c>.selectbox.

1 Like

Thank you very much for solving my problem. I thought I needed to add controls like this, but I was wrong