Callback function that use caller as argument?

I need to create a callback to a fucntion that use use the value of the widget that call the function.

my_sbox=st.selectbox("MysBox", options=["first","second"],key="s_box", on_change=myfunc())

It does not work because the function is not defined before creating the widget, and if I exchange position of the function and of the widget, when the callback is called, then the widget is not yet created.

Any idea if I can solve this?

Use st.session_state.s_box to access the value in callbacks.

Thanks a lot, it is working well with session_state.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.