Retrieve value of st.text or st.metric

Hi the community.

In an app I need to retrieve the value of a st.text or st.metric.
Do I need to use session_state or is there another way?

What value? Display elements don’t have a value, they just display whatever you tell them to display.

Yes but I was wondering if the displayed text/ number fro ma display widget could be accessed.

For example, I display the result of a calculation in st.text or st.metric based on values from a form.
In further processing, I need to know if the displayed text/metric is empty or not.

I cannot use a st.text_input or st.number_input because I don’t want the user to be able to modify this value manually.

So tit seems that the only way t ogo forward is to store the result of the calculation in a global variable (or session_state) and use this value to be displayed in my st.text widget and to be used for further downstream processing.

Yes, if you want to use the result in several places you need to store it somewhere.