diff --git a/README.md b/README.md index bb7046b..716c9d4 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,10 @@ #### 画像ビューアー(中央) - **フレーム番号スライダー**: マウスでスライダーを動かして、画像を前後にスクロール +- **キーボードショートカット**: + - `←` または `a`: 前のフレームに移動 + - `→` または `f`: 次のフレームに移動 +- **◀▶ボタン**: クリックでフレームを1つずつ移動 - 1症例あたり約20フレームの画像を確認できます #### 症例ナビゲーション(サイドバー上部) diff --git a/app.py b/app.py index f4f66ea..9410dfd 100644 --- a/app.py +++ b/app.py @@ -70,7 +70,7 @@ doc.addEventListener('keydown', function(e) { const active = doc.activeElement; - + // 【重要】テキスト入力中のみ除外するロジックを修正 // TEXTAREA は無条件で除外(コメント入力など) // INPUT は type="range" (スライダー) 以外の場合のみ除外(名前入力など) @@ -83,7 +83,7 @@ const buttons = Array.from(doc.querySelectorAll('button')); - if (e.key === 'ArrowLeft') { + if (e.key === 'ArrowLeft' || e.key === 'a' || e.key === 'A') { const prevBtn = buttons.find(b => b.innerText.includes('◀')); if (prevBtn) { // ブラウザのデフォルト動作(スライダー移動など)をキャンセル @@ -91,7 +91,7 @@ e.stopPropagation(); prevBtn.click(); } - } else if (e.key === 'ArrowRight') { + } else if (e.key === 'ArrowRight' || e.key === 'f' || e.key === 'F') { const nextBtn = buttons.find(b => b.innerText.includes('▶')); if (nextBtn) { e.preventDefault(); @@ -198,6 +198,8 @@ # Data Directory Path with folder picker st.markdown("**データディレクトリパス** *") st.caption("症例フォルダ(CHIBAMI_xxx_pre)が含まれるディレクトリを選択してください") + if not TKINTER_AVAILABLE: + st.caption("⚠️ Windowsでのみ参照ボタンが利用可能です。MacOS/Linuxの場合はパスを直接入力してください") col1, col2 = st.columns([4, 1]) with col1: @@ -205,7 +207,7 @@ "データディレクトリパス", value=st.session_state.temp_data_root, help="「📁 参照」ボタンでフォルダを選択してください", - placeholder="「📁 参照」ボタンでフォルダを選択", + placeholder="「📁 参照」ボタンでフォルダを選択、またはパスを直接入力", label_visibility="collapsed" ) # Update session state when user types @@ -213,7 +215,7 @@ st.session_state.temp_data_root = data_root with col2: - if st.button("📁 参照 (Windowsでのみ利用可能 MacOS, Linuxの場合はパスを入力)", key="btn_browse_data", use_container_width=True): + if st.button("📁 参照", key="btn_browse_data", use_container_width=True): if TKINTER_AVAILABLE: # Use current path as initial dir if exists, otherwise use home directory initial = st.session_state.temp_data_root if st.session_state.temp_data_root else os.path.expanduser("~") @@ -235,6 +237,8 @@ # Excel Label Path with file picker st.markdown("**Excelラベルファイルパス** *") st.caption("正解ラベルが記載されたExcelファイル(CHIBAMI_case_list_xxx.xlsx)を選択してください") + if not TKINTER_AVAILABLE: + st.caption("⚠️ Windowsでのみ参照ボタンが利用可能です。MacOS/Linuxの場合はパスを直接入力してください") col1, col2 = st.columns([4, 1]) with col1: @@ -242,7 +246,7 @@ "Excelラベルファイルパス", value=st.session_state.temp_excel_path, help="「📄 参照」ボタンでExcelファイルを選択してください", - placeholder="「📄 参照」ボタンでファイルを選択", + placeholder="「📄 参照」ボタンでファイルを選択、またはパスを直接入力", label_visibility="collapsed" ) # Update session state when user types @@ -250,7 +254,7 @@ st.session_state.temp_excel_path = excel_path with col2: - if st.button("📄 参照 (Windowsでのみ利用可能 MacOS, Linuxの場合はパスを入力)", key="btn_browse_excel", use_container_width=True): + if st.button("📄 参照", key="btn_browse_excel", use_container_width=True): if TKINTER_AVAILABLE: # Use directory of current path as initial dir if exists initial = os.path.dirname(st.session_state.temp_excel_path) if st.session_state.temp_excel_path else os.path.expanduser("~") @@ -516,7 +520,7 @@ container.error(f"画像読み込みエラー: {e}") # Keyboard navigation support (キーボードの矢印キーでフレーム移動) - container.caption("💡 ヒント: スライダーをクリックしてから矢印キー(←→)でフレーム移動、または◀▶ボタンをクリックできます") + container.caption("💡 ヒント: スライダーをクリックしてから矢印キー(←→)またはキー(a/f)でフレーム移動、または◀▶ボタンをクリックできます") inject_keyboard_shortcuts()