build_tools.pipeline_tui.screens.file_selector ============================================== .. py:module:: build_tools.pipeline_tui.screens.file_selector .. autoapi-nested-parse:: File selector screen for Pipeline TUI. This module provides a modal screen for selecting specific files from a directory. Users can browse to a directory, see matching files, and select/deselect individual files or use select all/none for batch operations. **Features:** - Directory tree navigation to find source folders - File list with checkboxes for selection - Select All / Select None buttons - File pattern filtering - Summary of selected files count **Example Usage:** .. code-block:: python from build_tools.pipeline_tui.screens.file_selector import FileSelectorScreen result = await self.app.push_screen_wait( FileSelectorScreen( initial_dir=Path("_working/codex"), file_pattern="*.txt", ) ) if result: selected_files = result # List[Path] print(f"Selected {len(selected_files)} files") Classes ------- .. autoapisummary:: build_tools.pipeline_tui.screens.file_selector.FileSelectorScreen Module Contents --------------- .. py:class:: FileSelectorScreen(initial_dir = None, file_pattern = '*.txt', title = 'Select Files', root_dir = None) Bases: :py:obj:`textual.screen.ModalScreen`\ [\ :py:obj:`list`\ [\ :py:obj:`pathlib.Path`\ ]\ :py:obj:`| None`\ ] Modal screen for selecting multiple files from a directory. Displays a directory browser and a file list with checkboxes. When user navigates to a directory, shows all files matching the pattern with checkboxes for selection. .. attribute:: initial_dir Starting directory for browser .. attribute:: file_pattern Glob pattern for filtering files (default: "*.txt") .. attribute:: current_dir Currently browsed directory .. attribute:: selected_files Set of selected file paths :returns: List of selected Path objects, or None if cancelled Initialize file selector screen. :param initial_dir: Starting directory for browser (default: home) :param file_pattern: Glob pattern for files (default: "*.txt") :param title: Header title for the screen :param root_dir: Root directory for tree navigation (default: home). Set higher than initial_dir to allow navigating up. .. py:attribute:: BINDINGS :value: [('escape', 'cancel', 'Cancel'), ('enter', 'confirm', 'Confirm'), ('a', 'select_all', 'Select... A list of key bindings. .. py:attribute:: CSS :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ FileSelectorScreen { align: center middle; } #file-selector-container { width: 100; height: 40; background: $panel; border: thick $primary; padding: 1; } #selector-header { text-align: center; text-style: bold; color: $accent; margin-bottom: 1; } #main-panels { width: 100%; height: 1fr; } #dir-panel { width: 40%; height: 100%; border: solid $primary; padding: 0 1; } #file-panel { width: 60%; height: 100%; border: solid $primary; padding: 0 1; } .panel-header { text-style: bold; color: $text; margin-bottom: 1; } #directory-tree { width: 100%; height: 1fr; } #file-list { width: 100%; height: 1fr; } .file-checkbox { margin: 0; padding: 0; } #status-bar { height: 2; width: 100%; color: $text-muted; border-top: solid $primary; padding: 0 1; margin-top: 1; } #button-bar { width: 100%; height: auto; align: center middle; margin-top: 1; } #button-bar Button { margin: 0 1; } .empty-message { color: $text-muted; text-align: center; padding: 2; } """ .. raw:: html
Inline CSS, useful for quick scripts. Rules here take priority over CSS_PATH. .. note:: This CSS applies to the whole app. .. py:attribute:: initial_dir .. py:attribute:: root_dir .. py:attribute:: file_pattern :value: '*.txt' .. py:attribute:: title_text :value: 'Select Files' .. py:attribute:: current_dir :type: pathlib.Path | None :value: None .. py:attribute:: selected_files :type: set[pathlib.Path] .. py:method:: compose() Compose the file selector UI. .. py:method:: directory_selected(event) :async: Handle directory selection in tree. .. py:method:: node_expanded(event) :async: Handle directory expansion - also load files. .. py:method:: checkbox_changed(event) Handle file checkbox toggle. .. py:method:: select_all_pressed() Select all visible files. .. py:method:: select_none_pressed() Deselect all visible files. .. py:method:: select_pressed() Confirm selection and dismiss. .. py:method:: cancel_pressed() Cancel and dismiss. .. py:method:: action_cancel() Cancel action (escape key). .. py:method:: action_confirm() Confirm action (enter key). .. py:method:: action_select_all() Select all files (a key). .. py:method:: action_select_none() Deselect all files (n key). .. py:method:: on_mount() :async: Handle screen mount event. If initial_dir differs from root_dir, expand the tree to show initial_dir after a brief delay. .. py:method:: action_cursor_down() Move cursor down in directory tree (j key). .. py:method:: action_cursor_up() Move cursor up in directory tree (k key). .. py:method:: action_cursor_left() Collapse directory in tree (h key). .. py:method:: action_cursor_right() Expand directory in tree (l key). .. py:method:: action_toggle_node() Toggle expand/collapse of current node (space key).