Blocking user input widget

I am developing a streamlit application. In one point we are calling a callback function that needs to render an input field to get the user response and return True or False based on users input. The problem is that we need to wait the user input to continue with callback function execution but with the next code the run loop gets stuck on the while statement.

I understand that the widget is not working because streamlit needs to re-render all time the widgets to get the state/value and so on, but we don’t see how to do it then because the function must not continue till we evaluate the user input (remember we are inside a function).

We tried the the built in python function input and works because properly blocks the execution.

## Define the human validator
def _approve(_input: str) -> bool:
    
    msg = (
        "Do you want to continue? Make sure the information below is correct."
    )
    msg += "\n\n" + _input + "\n"
    
    # input the answer in the shown space in the terminal
    # expr = st.chat_input(msg)
    # insert an input at the confirmation placeholder
    expr = st.text_input(msg, value="", key="confirmation")
    
    while expr == "":
        print("Please, provide an input")
        pass
    
    print("Input provided by the user:", expr)
        
    # classify if the answer provided in the terminal is positive or not
    resp = is_positive_answer(expr)
    resp = resp.strip()
    print("Interpretation of the natural language:", resp)
  
    # user-friendly information displayed in the terminal
    if resp.lower() in ('yes'):
        print('\n Continuing.... \n')
    
    if resp.lower() not in ('yes'):
        print('\n Breaking.... \n')
    
    # if the answer is positive, the thread continues
    # if the answer is negative, the thread breaks
    return resp.lower() in ('yes')

Hi @maparla-cognizant

Have you tried using the disabled parameter in st.text_input() in order to deactivate the text input by default when no _input is provided. However upon user-provided input, the widget would be activated followed by running downstream statements.

An example of using the disabled parameter was implemented in this app: https://github.com/dataprofessor/llama2/blob/master/streamlit_app_v2.py