Streamlit reset st.radio to default values on "Next" button

Ask the community or our support engineers for answers to questions.I am working on a image crowdsourcing app based on streamlit. After answering some questions in form of st.radio option, I move to next image but st.radio options stays same as for the previous image.

col1, col2 = st.columns(2)
with col1:
        image = Image.open(os.path.join(img_dir, selected_image))
        st.header("Original")
        st.image(image)

    with col2:
        image1 = image_mask
        st.header("Annotated Image")
        st.image(image1)
hint()

def hint():
    options = ["Select from below","Yes", "No"]
    st.radio("Question 1?", options, key = "q1")
    st.radio('Question2', 
    options=["Select","No Object","Doesn't match ", 'Poor', 'Average', 'Good', 'Perfect'], key="q2")
    pre, nex = st.columns(2)
    def previous_img():
        st.session_state.index = st.session_state.index - 1
        #st.write("current index",st.session_state.index)
    with pre:
        if st.session_state.index >=1:
            st.button("Previous Image", on_click=previous_img)
    with nex:
        if st.session_state.index <=3:
            st.button("Next Image", on_click=forward_choice, args=(index,))
        else:
            st.button("Submit Images", on_click=forward_choice, args=(index,))

On click next, script re-runs and “index + 1” displays next image but the options selected for previous image doesn’t change. I want to reset it in such way that when I go to next image, it reset backs to “select” option.

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