diff --git a/app.py b/app.py index a0d8e12..65c2d13 100644 --- a/app.py +++ b/app.py @@ -366,6 +366,10 @@ f"症例 {cid}" + (" ✓" if cid in st.session_state.annotated_cases else "") for cid in st.session_state.case_ids ] + + # 症例選択のコールバック + def on_case_change(): + pass selected_idx = st.selectbox( "症例リスト", @@ -379,15 +383,29 @@ st.session_state.current_case_idx = selected_idx st.rerun() + # 前後の症例移動ボタンのコールバック + def change_case(amount: int): + new_idx = st.session_state.current_case_idx + amount + if 0 <= new_idx < len(st.session_state.case_ids): + st.session_state.current_case_idx = new_idx + col1, col2 = st.columns(2) with col1: - if st.button("← 前へ", disabled=st.session_state.current_case_idx == 0, use_container_width=True): - st.session_state.current_case_idx -= 1 - st.rerun() + st.button( + "← 前へ", + disabled=st.session_state.current_case_idx == 0, + use_container_width=True, + on_click=change_case, + args=(-1,) + ) with col2: - if st.button("次へ →", disabled=st.session_state.current_case_idx >= len(st.session_state.case_ids) - 1, use_container_width=True): - st.session_state.current_case_idx += 1 - st.rerun() + st.button( + "次へ →", + disabled=st.session_state.current_case_idx >= len(st.session_state.case_ids) - 1, + use_container_width=True, + on_click=change_case, + args=(1,) + ) st.markdown("---") @@ -545,7 +563,7 @@ "Q4: 自由記述", value="", key=f"comment_{case_id}", - height=68, # 変更: 高さを約2行分に縮小 + height=120, label_visibility="collapsed" )