Hi,
I have problem with collecting responses and write it as a list.
With this code i can append the links to the list. However, for the first link i chose “Yes” but it didn’t append the first link.
I think there is an index shift when adding the list of links. Even if the selectbox for the first link is Yes, it starts adding from the 2nd link.
with st.form("my_form"):
col1, col2 = st.columns(2)
if st.session_state.papers:
if st.session_state.count < len(st.session_state.papers):
st.write("Progress: ", st.session_state.count + 1 , "/", len(st.session_state.papers))
text = st.session_state.papers[st.session_state.count]["Description"]
link = st.session_state.papers[st.session_state.count]["Link"]
label = st.selectbox("Do you want to include this resource to your content?:", [None,"Yes","No"], index=None)
st.write(link)
res_box = st.empty()
for i in range(len(text) + 1):
res_box.markdown(" %s" % text[0:i])
time.sleep(0.003)
if label == "Yes":
st.session_state.final_text.append(text)
st.session_state.final_link.append(link)
st.session_state.count += 1
with col2:
if st.form_submit_button("Next ⏭️"):
next_quote()
st.session_state.label_list.append(label)
pass
if st.session_state.count > 1:
with col1:
if st.form_submit_button("⏮️ Previous"):
previous_quote()
st.session_state.label_list.pop()
if st.session_state.label_list[-1] == "Yes":
st.session_state.final_text.pop()
st.session_state.final_link.pop()
pass
if index >= len(st.session_state.papers):
st.write("All done!")
final_submit = st.form_submit_button("Final Submit")
if final_submit:
for text in st.session_state.final_text:
final_text += text + "\n"
st.write(st.session_state.final_link)