Код: Выделить всё
@st.fragment
@st.dialog("Enter Your Input")
def get_user_input_popup(prompt_text):
if 'dialog_waiting' not in st.session_state:
st.session_state.dialog_waiting = True
if st.session_state.dialog_waiting:
with st.form("popup_form"):
user_input = st.text_input("Your response:", placeholder="Type here...")
col1, col2 = st.columns(2)
with col1:
submit = st.form_submit_button("Submit", type="primary")
with col2:
cancel = st.form_submit_button("Cancel")
if submit and user_input.strip():
st.session_state.dialog_result = user_input.strip()
st.session_state.dialog_waiting = False
st.rerun(scope="fragment")
elif cancel:
st.session_state.dialog_result = "CANCELLED"
st.session_state.dialog_waiting = False
st.rerun(scope="fragment")
elif submit:
st.error("Please enter some text!")
return None
else:
return st.session_state.dialog_result
Код: Выделить всё
with st.spinner("Waiting for input..."):
response = get_user_input_popup("Need more info:")
print("\n\n", response, "\n\n", type(response))
и если я не использую строки St.Rerun в функции, то выполнение увеличивает все в функции всплывающего окна и просто не возвращает ни одного.>
Подробнее здесь: https://stackoverflow.com/questions/797 ... entire-app