How to pass the value of a widget as an arg of its callback function?

Hello everybody,
How can I pass the value of a widget as an argument of its callback function?
I tried doing like this but it gives me this error: st.session_state has no attribute “link_input”. Did you forget to initialize it?

link = st.text_input(label="Insert link", value="", max_chars= 100,key="link_input", placeholder="Example: bla", help="Be sure to insert a valid URL", on_change=adogniletterainserita, args=[st.session_state.link_input] 

You don’t need to pass the key “link_input” in the args.
In your function “adogniletterainserita” just call st.session_state["link_input"]

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