Update text_area

Summary

Hi,
I want to update my text inside a text area.

Steps to reproduce

Code snippet:

my_area =  st.text_area(":blue[My text here :]",height=2000)
new_text = My_function(my_area)
my_area = st.text_area(":blue[My text here :]",new_text,height=2000)

I’m not entirely clear on the flow you want, but one way to accomplish this is to set the default value of your textbox to be based on a value in st.session_state, and then update that value in the session state and rerun the app

import streamlit as st

if "default" not in st.session_state:
    st.session_state["default"] = "Default text" * 100

my_area = st.text_area(
    ":blue[My text here :]", value=st.session_state["default"], height=2000
)

if st.button("Update default example"):
    st.session_state["default"] = "Updated text" * 100
    st.experimental_rerun()

Thanks for the answer. Thats my code :

text = st.text_area(β€œ:blue[Enter text :]”,height=100)

def Upper_Text(text):
upper_text = text.upper()
return upper_text

if st.button(β€œUpper Text”):
text = st.text_area(β€œ:blue[Enter text :]”,Upper_Text(text),height=2000)

And this is the result :

I want to display the result in the same text area and not create another one.

It’s good.

Hi @ttuz! Did you achieve this?