lolo
1
I’d like to call a function when i click on a st.form_submit_button.
I read that it is possible to use , for example, the syntax “on_click=my_function()”
But the problem is that my function returns values : i would normally use it like this : value1, value2=my_function() .
So how can i write it with the parameter on_click ?
→ like this : on_click=values1, values2=my_function() ?
Goyo
2
I don’t think you need a callback to do that.
import streamlit as st
def my_function():
return "foo", "bar"
with st.form(key="form"):
text = st.text_input("Text")
submit = st.form_submit_button()
if submit:
value1, value2 = my_function()
st.write(f"Text: {text}")
st.write(f"Value 1: {value1}")
st.write(f"Value 2: {value2}")
1 Like
system
Closed
3
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.