Callbacks with args
ChrisDelClea opened this issue · 2 comments
ChrisDelClea commented
Hey @okld ,
can i somehow pass args to a callback function?
def handle_onclick(event, args):
passed_arg = args[0]
mui.button("clickme", onClick=handle_onclick, args=("blub"))
Why args at all? I want to pass some information to the button as i have a button-list.
So i need somehow to save some information, what button was clicked.
lkdd-ao commented
Hey @okld ,
can i somehow pass args to a callback function?
def handle_onclick(event, args): passed_arg = args[0] mui.button("clickme", onClick=handle_onclick, args=("blub"))Why args at all? I want to pass some information to the button as i have a button-list. So i need somehow to save some information, what button was clicked.
You can do this
import streamlit as st
from functools import partial
def handle_onclick(args, event):
passed_arg = args
mui.button("clickme", onClick=partial(handle_onclick, "blub"))
ChrisDelClea commented
thanks, @lkdd-ao .