build_tools.pipeline_tui.screens.file_selector
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:
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
Modal screen for selecting multiple files from a directory. |
Module Contents
- class build_tools.pipeline_tui.screens.file_selector.FileSelectorScreen(initial_dir=None, file_pattern='*.txt', title='Select Files', root_dir=None)[source]
Bases:
textual.screen.ModalScreen[list[pathlib.Path]| 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.
- initial_dir
Starting directory for browser
- current_dir
Currently browsed directory
- selected_files
Set of selected file paths
- Returns:
List of selected Path objects, or None if cancelled
Initialize file selector screen.
- Parameters:
initial_dir (pathlib.Path | None) – Starting directory for browser (default: home)
file_pattern (str) – Glob pattern for files (default: “*.txt”)
title (str) – Header title for the screen
root_dir (pathlib.Path | None) – Root directory for tree navigation (default: home). Set higher than initial_dir to allow navigating up.
- BINDINGS = [('escape', 'cancel', 'Cancel'), ('enter', 'confirm', 'Confirm'), ('a', 'select_all', 'Select...
A list of key bindings.
- CSS = Multiline-String
Show Value
""" 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; } """
Inline CSS, useful for quick scripts. Rules here take priority over CSS_PATH.
Note
This CSS applies to the whole app.
- initial_dir
- root_dir
- file_pattern = '*.txt'
- title_text = 'Select Files'
- current_dir: pathlib.Path | None = None
- selected_files: set[pathlib.Path]