Streamlit 1.37 Release | New Features Explained

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น • 2

  • @amanahmed6057
    @amanahmed6057 5 หลายเดือนก่อน

    is thery any feature of streamlit in which if we select multiselect , more than 2 and drop down height increases every time , I know that we can make the drop down scrollablle but is there any way to use in expander , because when we use expander , it will shift all the graph to down , Its okay when you have 4 options but when you have 20 options in expander than it would shifted all the graph upto down ,which is very irritating.

    • @CuriosityDataAnalytics
      @CuriosityDataAnalytics  5 หลายเดือนก่อน

      When using st.multiselect(), the drop-down menu only shows around 7 options before having to scroll to see the other options.
      For example :
      # options
      options = ['Option ' + str(i+1) for i in np.arange(0,20,1)]
      # using multiselect
      st.multiselect('test', options)
      But you can tackle this issue by using st.expander(), looping on multiple st.checkbox() and using the st.session_state() to gather all selected options. This way, when you open the expander, all options will be displayed at once.
      # using expander + checkbox
      with st.expander('Choose an option'):
      for i in options:
      st.checkbox(i, key=i)
      selected_options = [key for key, value in st.session_state.items() if value is True]
      st.write(selected_options)
      Try this and let me know if it works