Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -339,10 +339,9 @@ def render_rupture_markers_widget(index: int, choices: list[str]):
|
|
| 339 |
Works inside a st.form by using form_submit_button instead of callbacks."""
|
| 340 |
count_key = f"rupture_count_{index}"
|
| 341 |
if count_key not in st.session_state:
|
| 342 |
-
st.session_state[count_key] = 1
|
| 343 |
|
| 344 |
count = st.session_state[count_key]
|
| 345 |
-
|
| 346 |
st.markdown("**What rupture markers are found?** *(one per row; max 8)*")
|
| 347 |
|
| 348 |
for i in range(1, count + 1):
|
|
@@ -361,33 +360,28 @@ def render_rupture_markers_widget(index: int, choices: list[str]):
|
|
| 361 |
if st.session_state.get(marker_key) in choices else 0)
|
| 362 |
if st.session_state.get(marker_key) is not None else 0
|
| 363 |
)
|
| 364 |
-
|
| 365 |
with col2:
|
| 366 |
if RUPTURE_LINE_INPUT_TYPE == "number":
|
| 367 |
-
st.number_input(f"Lines:
|
| 368 |
else:
|
| 369 |
-
st.text_input(f"Lines:
|
| 370 |
-
|
| 371 |
with col3:
|
| 372 |
if RUPTURE_LINE_INPUT_TYPE == "number":
|
| 373 |
-
st.number_input(f"Lines:
|
| 374 |
else:
|
| 375 |
-
st.text_input(f"Lines:
|
| 376 |
|
| 377 |
st.markdown("---")
|
| 378 |
|
| 379 |
-
# Use SUBMIT buttons (legal inside forms) to add/remove rows.
|
| 380 |
a_col, b_col = st.columns([1, 1])
|
| 381 |
with a_col:
|
| 382 |
add_clicked = st.form_submit_button(
|
| 383 |
"➕ Add another rupture marker",
|
| 384 |
-
key=f"add_rup_{index}",
|
| 385 |
disabled=(count >= MAX_RUPTURE_MARKERS),
|
| 386 |
)
|
| 387 |
with b_col:
|
| 388 |
remove_clicked = st.form_submit_button(
|
| 389 |
"➖ Remove last",
|
| 390 |
-
key=f"remove_rup_{index}",
|
| 391 |
disabled=(count <= 1),
|
| 392 |
)
|
| 393 |
|
|
|
|
| 339 |
Works inside a st.form by using form_submit_button instead of callbacks."""
|
| 340 |
count_key = f"rupture_count_{index}"
|
| 341 |
if count_key not in st.session_state:
|
| 342 |
+
st.session_state[count_key] = 1
|
| 343 |
|
| 344 |
count = st.session_state[count_key]
|
|
|
|
| 345 |
st.markdown("**What rupture markers are found?** *(one per row; max 8)*")
|
| 346 |
|
| 347 |
for i in range(1, count + 1):
|
|
|
|
| 360 |
if st.session_state.get(marker_key) in choices else 0)
|
| 361 |
if st.session_state.get(marker_key) is not None else 0
|
| 362 |
)
|
|
|
|
| 363 |
with col2:
|
| 364 |
if RUPTURE_LINE_INPUT_TYPE == "number":
|
| 365 |
+
st.number_input(f"Lines: from", min_value=1, step=1, key=a_key)
|
| 366 |
else:
|
| 367 |
+
st.text_input(f"Lines: from", key=a_key, value=st.session_state.get(a_key, ""))
|
|
|
|
| 368 |
with col3:
|
| 369 |
if RUPTURE_LINE_INPUT_TYPE == "number":
|
| 370 |
+
st.number_input(f"Lines: to", min_value=1, step=1, key=b_key)
|
| 371 |
else:
|
| 372 |
+
st.text_input(f"Lines: to", key=b_key, value=st.session_state.get(b_key, ""))
|
| 373 |
|
| 374 |
st.markdown("---")
|
| 375 |
|
|
|
|
| 376 |
a_col, b_col = st.columns([1, 1])
|
| 377 |
with a_col:
|
| 378 |
add_clicked = st.form_submit_button(
|
| 379 |
"➕ Add another rupture marker",
|
|
|
|
| 380 |
disabled=(count >= MAX_RUPTURE_MARKERS),
|
| 381 |
)
|
| 382 |
with b_col:
|
| 383 |
remove_clicked = st.form_submit_button(
|
| 384 |
"➖ Remove last",
|
|
|
|
| 385 |
disabled=(count <= 1),
|
| 386 |
)
|
| 387 |
|