streamlit icon indicating copy to clipboard operation
streamlit copied to clipboard

Automatically generate user_key for widgets

Open PaleNeutron opened this issue 1 year ago • 0 comments

Problem

Currently, widgets with exactly same parameters will get same widget id which cause error, for eg.

import streamlit as st

st.date_input("day")
st.date_input("day")

And user have to provide a key value to make it work.

Solution

In my code, I usually do this by:

import streamlit as st
key_gen = iter(range(10000))

st.date_input("day", key=next(key_gen))
st.date_input("day", key=next(key_gen))

So why streamlit not do this automatically?

PaleNeutron avatar Sep 21 '22 08:09 PaleNeutron