In Streamlit how to Identify source widget when multiple widgets share the same callback

#Same Call Back Function for all the widgets
def change_other_filters(key,value,filters_data):
column_name_key=key[1:]
column_values=value
remaining_filters=filter_names.remove(key)
for filter in remaining_filters:
filters_data[filter]= list(filters_data.query(β€œ@column_name_key == @column_values”
[filter].unique())

#creating widgets in for loop with same callback function
filter_boxes = {}
for i in range(len(filter_names)):
options = list(filters_data[filter_names[i]].astype(str).unique())
options.sort()
filter_boxes[filter_names[i]] = st.sidebar.multiselect(label=f’SELECT {filter_names[i]} β€˜,
key=f’k{filter_names[i]}’,
options=[β€˜All’] + options,
default=β€˜All’,
on_change=change_other_filters(key,filter_boxes[filter_names[i]],filters_data)

#HOW TO KNOW WHICH WIDGET CALLED THE CALLBACK FUNCTION

Hi there,

Thanks for sharing your question with the community! Check out our guidelines on how to post an effective question here – in particular, please format your code properly and explain your question in more detail.

Caroline :balloon:

Thankyou Caroline

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