Here is a minimal example:
import streamlit as st
def display_button():
if st.button("Display text"):
display_textbox()
def display_textbox():
my_text = st.text_input("Input some text here")
st.markdown(my_text)
def main():
display_button()
if __name__ == "__main__":
main()
If I press the button, it will display a text input box. When I enter text into the box and hit enter, st.markdown()
does not run, and indeed the text box disappears as well.
If, in main()
, we instead call display_textbox()
, then it will print out the textbox and any input text as expected.
I’m not sure if it’s related to this? If so, would using radio buttons or checkboxes be the only way to bypass this problem?