I have a project, where i need around 40 input fields, with default values, on the same page.
Do anybody have any good idea on how to approach this ?
Currently i have created a lot of column, but using st.text_input gives me the following error ( DuplicateWidgetID), when i have multiple with the same default value.
No worries I can solve the DuplicateWidgetID error for you!
So that comes up when you have multiple widgets that are identical! for example:
import streamlit as st
text = st.text_input("Type here")
text2 = st.text_input("Type here") # <-- this throws the error
Thats because widgets are assigned an internal key based on its structure. So identically structured widgets end up with the same internal key.
The way around this is by using the key parameter. This adds a unique string to the end of the generated key, so that Streamlit knows which input is from which widget! I usually add something that makes sense to me and how the widgets are actually used differently. So in this silly example:
I think i know exactly what you are thinking. That is a really good idea, and would also allow me to select which rows i need, and not like today, where they are all shown.
I need to wrap my head around how to do it, but that would make my code so much easier, if i’m right.