Good day everyone!
I’m currently building a (for now) local search engine, so far so good.
Most of it works, but I’m breaking my brain for the last two days on how to get st.pills to behave like I want/imagine.
The goal is to have pills, reload it’s available tags, as soon as new selection was made.
Doesn’t sound too complicated, but somehow I’m completely stuck on that part.
Right now it looks like this:
and when a pill is selected the search does update correctly, as well as the df behind it.
But it should reduce the possible pill select down to the tags shown under the image “mid mod…”
my code rn is a mess, however, the important(?) bits are here:
def pills(avail_tags, df_start, color_selection):
tag_selection =st.pills('Tags',avail_tags, selection_mode='multi')
df_start, avail_tags, tag_selection = filter_fragment(df_start, color_selection ,tag_selection)
st.write(tag_selection)
st.write(avail_tags)
return df_start
@st.fragment
def filter_fragment(df_start, color_selection ,tag_selection):
avail_tags = button_tag_list(df_start)
search_input = color_selection["color_name"].to_list() + tag_selection
df_start, df_data = color_search_func(df_start, search_input)
st.write(df_start)
return df_start, avail_tags, tag_selection
def filter_color(df_start, color_selection):
avail_tags = button_tag_list(df_start)
search_input = color_selection["color_name"].to_list()
df_start, df_data = color_search_func(df_start, search_input)
return df_start, avail_tags
and
elif search_method == 'Tag filter':
#df_colors = get_availible_colors()
color_picker = DynamicFilters(get_availible_colors(), filters=['color_name'])
color_picker.display_filters()
df_chosen_colors = color_picker.filter_df()
search_input = df_chosen_colors["color_name"]
df_start, df_data = color_search_func(df_data, search_input)
if len(df_start) >= 1:
if color_picker:
df_start, avail_tags = filter_color(df_start, df_chosen_colors)
df_start = pills(avail_tags, df_start, df_chosen_colors)
It would be super awsome if one of you could lead me to the solution ![]()
The code is running on python 3.12.8 latest mac OS
pip freeze:
streamlit==1.52.0
streamlit_dynamic_filters==0.1.9
direct link to st folder on github:


