I am still a newbie dev, My question is there a way to remove the default output of streamlit?
what I mean is I use st.input command and every time I run it, streamlit provides a default value as the output even though i haven’t put anything as input I tried to configure it and change the magic to false in the configuration setting of streamlit but still the same.
Could you share your code snippet or a link to your GitHub repo.
I created basic code to show what I am asking
import streamlit as st
first_val = st.number_input(“Enter number:”)
second_val = st.number_input(“Enter second number”)
add_val = first_val + second_val
if your going to check the image above, I put 3 as an input then streamlit show it right away . What I want to happen is streamlit show an output after calculation. I guess it got something to do with the magic command? i try to turn it off but its still the same so I dont have an dea
You can embed your code inside
st.form then use conditionals to display the sum value after the submit button is clicked.
Here’s a revised version of this:
first_value = st.number_input('Enter number:')
second_value = st.number_input('Enter second number:')
submitted = st.form_submit_button('Submit')
add_value = first_value + second_value
Now, the output will only be shown after the submit button is clicked.
I’ve created a GitHub repo here st-form-example/streamlit_app.py at master · dataprofessor/st-form-example · GitHub
And a demo app of this here https://dataprofessor-st-form-example-streamlit-app-rz5jl9.streamlitapp.com/
Hope this helps