gagan3012 / streamlit-tags

Custom Tag component for streamlit
https://streamlit-tags.readthedocs.io/en/latest/
MIT License
281 stars 17 forks source link

Tags does not get updated upon button click event #28

Open hassiahk opened 3 years ago

hassiahk commented 3 years ago

I am trying to update the tags upon a button click event but the tags are not getting updated.

I have a list of tags that I define at the start and then upon clicking the button this list gets updated but st_tags component does not update the tags. Below is the script I am using:

import streamlit as st
from streamlit_tags import st_tags

tags = ['hello', 'world']
options = ['hey', 'hi']

add_button = st.sidebar.button("SUBMIT")
if add_button:
    tags = ['hello', 'python']

custom_keywords = st_tags(
    label="",
    text="Press enter to add more",
    value=tags,
    suggestions=options,
    maxtags=15,
    key="1",
)

st.multiselect does update the options upon clicking the button.

original_keywords = st.multiselect(
    "Choose a word",
    options,
    tags,
)

Any way I can achieve this with st_tags? 😄

Thanks in advance!

gagan3012 commented 3 years ago

Hello, Yes it can be done I will include it in the coming release

hassiahk commented 3 years ago

Hello, Yes it can be done I will include it in the coming release

That would be great to have!

Any workaround for now? I am pretty new to streamlit 😄

gagan3012 commented 3 years ago

Hi, So the tags that are supplied cannot be changed as it takes static input only because the tags we provide are just starting points since we have a manual input method the I choose not to have it updated every time to maintain the stability of streamlit-tags

To do something like this we can input them manually from the UI.

rolandgvc commented 2 years ago

Any updates on this?