I have a very simple streamlit ketcher implementation that draws a molecule, which I then want to have a button to store the content. This is the section of code that’s relevant, I’ve removed references to other elements not in play.
scaffold_list = []
scaffold = ""
col1, col2, col3 = st.columns([50, 30, 20])
with col1:
scaffold = st_ketcher(height=650, molecule_format="MOLFILE", key="ketcher")
if st.button(
"Store Core",
):
if len(scaffold) > 0 and scaffold not in scaffold_list:
scaffold_list.append(scaffold)
st.write("Cores to Run")
for scaffold in scaffold_list:
# DO STUFF
So far, so good, but what I’ve found is that, despite scaffold_list being global, every time I update the ‘scaffold’ ketcher object with apply, the list is cleared and I can’t store anything. What am I missing to keep that list of strings alive? I don’t normally have to put non Streamlit elements in session storage, but I’m wondering if that’s what’s needed