Issue with st.empty()

Hello all,

I am facing a special issue as shown in the recording. The following is what I require in steps.

  1. Select an option from the selectbar
  2. Login with the credentials
  3. On successful login, the login and password text_inputs should be vanished and file_uploader should arise.
  4. After this a text_input for number of layers should be present.

The problem is as follows.
The moment I enter the input and press enter, the text_input vanishes and previously hidden login text_inputs are again shown.

Please let me know if you have any solution for this. Thanks in advance.

file:///C:/Users/CDS/Downloads/streamlit-sample-2020-12-01-21-12-56.webm

Hey @Harish_Kodarapu,

We actually cant see your screen recording, as you canโ€™t post screen recordings on the forum. I imagine your having an issue with the statefulness of your app based on your description. Because the text_input fields do not preserve the users selection after multiple clicks/interactions on the page, when you hit enter on the second text_input it resets the app and it runs the script from top to bottom again.

We are currently creating a session state for streamlit to combat this very thing. IN the mean time there are some workarounds:

Also, checkout our state survey if you want to be involved in the development of session state!

Happy Streamlit-ing!
Marisa

Have you found a solution to this problem?

I am facing something similar.

Hi @oltipreka,

With the release of session state this should no longer be an issue for you! :tada:

You can store the values of all of your widgets in the state object and then use them on reruns of your app to dynamically change the output! :partying_face:

Check out the blog post here: Store Information Across App Interactions | Session State

State API here: Session State API โ€” Streamlit 0.86.0 documentation

Upgrade Streamlit to 0.84 or above to be able to use this new feature!

Happy Streamlit-ing!
Marisa

1 Like