Before clicking “Create Topic”, please make sure your post includes the following information (otherwise, the post will be locked).
- Are you running your app locally or is it deployed?
Locally - Share the link to your app’s public GitHub repository (including a requirements file).
N/A - Share the full text of the error message (not a screenshot).
N/A - Share the Streamlit and Python versions.
Streamlit version: 1.30.0
Python version: 3.11.5
As described in the image, I want ticking a checkbox to not rerun the script (and this requires st.form
as I understand).
-
Using st.form context manager →
StreamlitAPIException: With forms, callbacks can only be defined on the st.form_submit_button. Defining callbacks on other widgets inside a form is not allowed.
This is because the magnifying glass has a callback. -
So I tried without the context manager:
form = st.form(key="query_results", clear_on_submit=True)
form.form_submit_button(label="Submit")
...
item_col1, item_col2, item_col3 = st.columns(
[0.3, 0.69, 0.01]
)
with item_col1:
st.button(
f"🔍",
key=button_key,
on_click=update_image_search_options,
)
with item_col3:
form.checkbox(
label="Export to disk",
key=f"checkbox_{random_id}_{sku_config}",
value=False,
label_visibility="collapsed",
)
but this just moves all the checkboxes together.
Is there an easy solution to this?