Spaces:
Sleeping
Sleeping
Timo
commited on
Commit
·
dca011f
1
Parent(s):
d885b74
Stale layout
Browse files- src/streamlit_app.py +17 -5
src/streamlit_app.py
CHANGED
|
@@ -80,6 +80,17 @@ def _on_set_changed():
|
|
| 80 |
st.toast(f"Switched to set {curr}. Cleared current pack & deck.")
|
| 81 |
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
if "model" not in st.session_state:
|
| 85 |
st.session_state.model = load_model() # your class
|
|
@@ -297,11 +308,12 @@ with tabs[0]:
|
|
| 297 |
"""
|
| 298 |
c2.markdown(tooltip_html, unsafe_allow_html=True)
|
| 299 |
with c3:
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
|
|
|
| 305 |
else:
|
| 306 |
st.caption("Pack is empty.")
|
| 307 |
|
|
|
|
| 80 |
st.toast(f"Switched to set {curr}. Cleared current pack & deck.")
|
| 81 |
|
| 82 |
|
| 83 |
+
def _pick_card(card: str):
|
| 84 |
+
# save undo before mutating
|
| 85 |
+
push_undo()
|
| 86 |
+
st.session_state["deck"].append(card)
|
| 87 |
+
|
| 88 |
+
# clear the whole pack and any transient widget values
|
| 89 |
+
st.session_state["pack"].clear()
|
| 90 |
+
|
| 91 |
+
# stop this run so nothing else re-renders with stale UI
|
| 92 |
+
|
| 93 |
+
|
| 94 |
|
| 95 |
if "model" not in st.session_state:
|
| 96 |
st.session_state.model = load_model() # your class
|
|
|
|
| 308 |
"""
|
| 309 |
c2.markdown(tooltip_html, unsafe_allow_html=True)
|
| 310 |
with c3:
|
| 311 |
+
st.button("Pick",
|
| 312 |
+
key=f"pick_btn_{i}",
|
| 313 |
+
use_container_width=True,
|
| 314 |
+
help="Add to deck & clear pack",
|
| 315 |
+
on_click=_pick_card, args=(card,),
|
| 316 |
+
)
|
| 317 |
else:
|
| 318 |
st.caption("Pack is empty.")
|
| 319 |
|