How to disable text input after user finish input?

how to disable text input after user finish input?
now use disabled=True will make input unavailable before user input something.
Thank you.

Anyone have solution for this requirement?
Thank you.

Sorry, your question is not clear to me.

Am I understanding correctly:
a) Your have a text input widget
b) once the user enters something in the input then you want the text input widget to disappear?

My suggestion is this

  1. Make an empty widget with st.empty
  2. In the empty widget you just made, create an st.form
  3. In the form you just made, include a st.text_input widget where the user can enter text.
  4. In the form you made, you have to include a button. When the button become “submitted” turn your form back into a nice message using something like st.write

So the basic idea is you go from

mywidget = st.empty → (mywidget = st.form + st.text.input) → mywidget = st.write

Does that make sense?

1 Like

Here’s an alternative to using forms and st.empty:

Solution

import streamlit as st

if "disabled" not in st.session_state:
    st.session_state["disabled"] = False

def disable():
    st.session_state["disabled"] = True

st.text_input(
    "Enter some text", 
    disabled=st.session_state.disabled, 
    on_change=disable
)

Output

text-input-disable

Best, :balloon:
Snehan

2 Likes

Thank you very much.