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.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.