build_tools.pipeline_tui.screens.configure ========================================== .. py:module:: build_tools.pipeline_tui.screens.configure .. autoapi-nested-parse:: Configure tab panel for Pipeline TUI. This module provides the ConfigurePanel widget which displays all configuration options for the syllable extraction pipeline. It allows users to: - Select source and output directories - Choose extractor type (pyphen or NLTK) - Configure language (for pyphen) - Set syllable length constraints - Toggle pipeline stages (normalize, annotate) **Design Principles:** - Uses shared tui_common controls for consistent UX - Posts messages for state changes (handled by parent app) - Clear visual grouping of related options - Keyboard-navigable (Tab between controls, Enter/Space to activate) **Message Flow:** The panel posts custom messages when configuration changes. The parent app handles these messages and updates the central PipelineState. Attributes ---------- .. autoapisummary:: build_tools.pipeline_tui.screens.configure.COMMON_LANGUAGES Classes ------- .. autoapisummary:: build_tools.pipeline_tui.screens.configure.ConfigurePanel Module Contents --------------- .. py:data:: COMMON_LANGUAGES :value: [('auto', 'Auto-detect'), ('en_US', 'English (US)'), ('en_GB', 'English (UK)'), ('de_DE',... .. py:class:: ConfigurePanel(source_path = None, selected_files = None, output_dir = None, extractor_type = ExtractorType.PYPHEN, language = 'auto', min_syllable_length = 2, max_syllable_length = 8, file_pattern = '*.txt', run_normalize = True, run_annotate = True, *args, **kwargs) Bases: :py:obj:`textual.containers.VerticalScroll` Configuration panel for pipeline settings. This widget contains all the configuration controls for setting up a syllable extraction pipeline run. It is designed to be composed within a TabPane in the main application. **Layout Structure:** .. code-block:: text ┌─────────────────────────────────────────────────────────┐ │ DIRECTORIES │ │ Source: /path/to/source [Browse] │ │ Output: /path/to/output [Browse] │ ├─────────────────────────────────────────────────────────┤ │ EXTRACTOR │ │ [x] Pyphen: Multi-language typographic hyphenation │ │ [ ] NLTK: English-only phonetic splitting │ ├─────────────────────────────────────────────────────────┤ │ LANGUAGE (Pyphen only) │ │ [x] English (US) [ ] German [ ] French [ ] Other │ │ Custom: [________] │ ├─────────────────────────────────────────────────────────┤ │ CONSTRAINTS │ │ Min Length: [2] │ │ Max Length: [8] │ │ File Pattern: [*.txt] │ ├─────────────────────────────────────────────────────────┤ │ PIPELINE STAGES │ │ [x] Run Normalization: Clean and deduplicate syllables │ │ [x] Run Annotation: Add phonetic features │ └─────────────────────────────────────────────────────────┘ .. attribute:: source_path Currently selected source directory .. attribute:: output_dir Currently selected output directory .. attribute:: extractor_type Selected extractor (PYPHEN or NLTK) .. attribute:: language Language code for pyphen (e.g., "en_US") .. attribute:: min_syllable_length Minimum syllable length filter .. attribute:: max_syllable_length Maximum syllable length filter .. attribute:: file_pattern Glob pattern for input files .. attribute:: run_normalize Whether to run normalization step .. attribute:: run_annotate Whether to run annotation step Messages: - :class:`SourceSelected`: Posted when source directory changes - :class:`OutputSelected`: Posted when output directory changes - :class:`ExtractorChanged`: Posted when extractor type changes - :class:`LanguageChanged`: Posted when language changes - :class:`ConstraintsChanged`: Posted when length constraints change - :class:`PipelineStagesChanged`: Posted when stage toggles change Initialize the ConfigurePanel with current configuration. :param source_path: Current source directory path :param selected_files: List of specific files to process (empty = use directory) :param output_dir: Current output directory path :param extractor_type: Current extractor type selection :param language: Current language code for pyphen :param min_syllable_length: Current minimum syllable length :param max_syllable_length: Current maximum syllable length :param file_pattern: Current file glob pattern :param run_normalize: Whether normalization is enabled :param run_annotate: Whether annotation is enabled :param \*args: Additional positional arguments passed to Static :param \*\*kwargs: Additional keyword arguments passed to Static .. py:class:: SourceSelected Bases: :py:obj:`textual.message.Message` Posted when the source directory is selected via browse button. Initialize the SourceSelected message. .. py:class:: FilesSelected Bases: :py:obj:`textual.message.Message` Posted when the user wants to select specific files. Initialize the FilesSelected message. .. py:class:: OutputSelected Bases: :py:obj:`textual.message.Message` Posted when the output directory is selected via browse button. Initialize the OutputSelected message. .. py:class:: ExtractorChanged(extractor_type) Bases: :py:obj:`textual.message.Message` Posted when the extractor type changes. .. attribute:: extractor_type The newly selected extractor type Initialize the ExtractorChanged message. :param extractor_type: The newly selected extractor type .. py:attribute:: extractor_type .. py:class:: LanguageChanged(language) Bases: :py:obj:`textual.message.Message` Posted when the language selection changes. .. attribute:: language The newly selected language code (e.g., "en_US") Initialize the LanguageChanged message. :param language: The language code .. py:attribute:: language .. py:class:: ConstraintsChanged(min_length, max_length, file_pattern) Bases: :py:obj:`textual.message.Message` Posted when syllable length constraints change. .. attribute:: min_length The new minimum syllable length .. attribute:: max_length The new maximum syllable length .. attribute:: file_pattern The file glob pattern Initialize the ConstraintsChanged message. :param min_length: Minimum syllable length :param max_length: Maximum syllable length :param file_pattern: File glob pattern .. py:attribute:: min_length .. py:attribute:: max_length .. py:attribute:: file_pattern .. py:class:: PipelineStagesChanged(run_normalize, run_annotate) Bases: :py:obj:`textual.message.Message` Posted when pipeline stage toggles change. .. attribute:: run_normalize Whether to run normalization .. attribute:: run_annotate Whether to run annotation Initialize the PipelineStagesChanged message. :param run_normalize: Whether normalization is enabled :param run_annotate: Whether annotation is enabled .. py:attribute:: run_normalize .. py:attribute:: run_annotate .. py:attribute:: DEFAULT_CSS :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ ConfigurePanel { width: 1fr; height: 1fr; padding: 1 2; } /* Section containers */ .config-section { width: 100%; height: auto; margin-bottom: 1; padding: 0 1; border: solid $primary-darken-2; } .section-header { text-style: bold; color: $accent; margin-bottom: 1; } /* Directory selection row */ .dir-row { height: 3; width: 100%; margin-bottom: 0; } .dir-label { width: 10; height: 3; content-align: center middle; text-align: right; padding-right: 1; } .dir-path { width: 1fr; height: 3; background: $boost; padding: 1; content-align: left middle; color: $text; } .dir-path-empty { color: $text-muted; text-style: italic; } .dir-button { width: 12; height: 3; margin-left: 1; } /* Extractor options */ .extractor-option { height: auto; padding: 0 1; } /* Language selector */ .language-row { height: auto; width: 100%; } .language-grid { width: 100%; height: auto; } .language-option { width: auto; margin-right: 2; } .custom-language-row { height: 3; margin-top: 1; } .custom-language-label { width: 10; height: 3; content-align: center middle; text-align: right; padding-right: 1; } .custom-language-input { width: 15; height: 3; } /* Language section disabled state */ .language-section-disabled { opacity: 0.5; } .language-section-disabled .language-option { color: $text-muted; } /* Constraints section */ .constraints-row { height: auto; width: 100%; } .pattern-row { height: 3; margin-top: 1; } .pattern-label { width: 15; height: 3; content-align: center middle; text-align: right; padding-right: 1; } .pattern-input { width: 15; height: 3; } /* Pipeline stages */ .stage-option { height: auto; padding: 0 1; } """ .. raw:: html
Default TCSS. .. py:attribute:: source_path :value: None .. py:attribute:: selected_files :value: [] .. py:attribute:: output_dir :value: None .. py:attribute:: extractor_type .. py:attribute:: language :value: 'auto' .. py:attribute:: min_syllable_length :value: 2 .. py:attribute:: max_syllable_length :value: 8 .. py:attribute:: file_pattern :value: '*.txt' .. py:attribute:: run_normalize :value: True .. py:attribute:: run_annotate :value: True .. py:method:: compose() Compose the configuration panel layout. Creates a vertically scrollable panel with grouped configuration sections for directories, extractor, language, constraints, and pipeline stages. :Yields: Configuration section widgets .. py:method:: on_source_browse_pressed(event) Handle source browse button press. Posts SourceSelected message to trigger directory browser in parent app. The parent app handles the actual directory selection modal. :param event: Button press event .. py:method:: on_output_browse_pressed(event) Handle output browse button press. Posts OutputSelected message to trigger directory browser in parent app. :param event: Button press event .. py:method:: on_select_files_pressed(event) Handle select files button press. Posts FilesSelected message to trigger file selector in parent app. :param event: Button press event .. py:method:: on_radio_option_selected(event) Handle radio option selection events. Routes the selection to appropriate handler based on widget ID: - extractor-*: Update extractor type - lang-*: Update language selection - stage-*: Toggle pipeline stage :param event: Radio option selected event .. py:method:: on_input_changed(event) Handle input field changes. Routes input changes to appropriate handler based on widget ID: - custom-language-input: Update language setting - file-pattern-input: Update file pattern :param event: Input change event .. py:method:: on_spinner_changed(event) Handle IntSpinner value changes. Routes spinner changes to update constraints based on widget_id. :param event: Spinner change event .. py:method:: update_source_path(path) Update the displayed source path. Called by parent app after directory selection. Clears any selected files since we're now using directory mode. :param path: New source path, or None if cleared .. py:method:: update_output_path(path) Update the displayed output path. Called by parent app after directory selection. :param path: New output path, or None if cleared .. py:method:: update_selected_files(files) Update the selected files list. Called by parent app after file selection. When files are selected, the source_path is used only as the initial browse location, not for processing. :param files: List of selected file paths