Streamlit is a Python-based WebUI tool, and it is not an exaggeration to say that it is a low-code tool. I used it to create a page for myself these days and generated a rule file in YAML format. I encountered a situation where interaction was needed in the middle, such as clicking a button to add an input box. After searching for a long time, I finally found the approach and code written by a foreign guy, and both the idea and the code are very good, so I recorded it here.
import streamlit as st
import random
import string
if 'input_keys' not in st.session_state:
st.session_state.input_keys= []
if st.button("Add new row"):
st.session_state.input_keys.append(random.choice(string.ascii_uppercase)+str(random.randint(0,999999)))
input_values = []
for input_key in st.session_state.input_keys:
input_value = st.text_input("Please input something", key=input_key)
input_values.append(input_value)