Streamlit Possible to Not Reload on Changing Input

Hi, I currently have a simple streamlit app. The goal is to take two parameters as input, then generate some text with them.

This is my app right now:

import streamlit as st

input1 = st.number_input('Input 1', min_value=1, max_value=20, value=5)
input2 = st.text_input('Input 2')

if st.button('Generate Some Text'):
   text = generate_text(input1, input2)

This is mostly working great. It takes in the two parameters, and generates text when the button is pressed.

There’s a couple things I would want to change if possible.

  1. Can I make it so the script will only rerun on pressing the button, and not when an input is changed?
  2. Is it possible to remove the ‘Press Enter to Apply’ popup text from text/number inputs?


1 Like

Hi Christian,

Welcome to the Streamlit forum. As far as I know, its not possible to make the script run only when the button is pressed, and not on every input change. Making the whole thing run on every input change is integral to how Streamlit works. There is st.stop(), but I don’t believe it does what you’re asking for.

I don’t know the answer to your second ask.


1 Like

Thanks. That’s what I figured, just wanted to confirm.