build_tools.pipeline_tui.screens.configure

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

COMMON_LANGUAGES

Classes

ConfigurePanel

Configuration panel for pipeline settings.

Module Contents

build_tools.pipeline_tui.screens.configure.COMMON_LANGUAGES = [('auto', 'Auto-detect'), ('en_US', 'English (US)'), ('en_GB', 'English (UK)'), ('de_DE',...
class build_tools.pipeline_tui.screens.configure.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)[source]

Bases: 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:

┌─────────────────────────────────────────────────────────┐
│ 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              │
└─────────────────────────────────────────────────────────┘
source_path

Currently selected source directory

output_dir

Currently selected output directory

extractor_type

Selected extractor (PYPHEN or NLTK)

language

Language code for pyphen (e.g., “en_US”)

min_syllable_length

Minimum syllable length filter

max_syllable_length

Maximum syllable length filter

file_pattern

Glob pattern for input files

run_normalize

Whether to run normalization step

run_annotate

Whether to run annotation step

Messages:

Initialize the ConfigurePanel with current configuration.

Parameters:
  • source_path (pathlib.Path | None) – Current source directory path

  • selected_files (list[pathlib.Path] | None) – List of specific files to process (empty = use directory)

  • output_dir (pathlib.Path | None) – Current output directory path

  • extractor_type (build_tools.pipeline_tui.core.state.ExtractorType) – Current extractor type selection

  • language (str) – Current language code for pyphen

  • min_syllable_length (int) – Current minimum syllable length

  • max_syllable_length (int) – Current maximum syllable length

  • file_pattern (str) – Current file glob pattern

  • run_normalize (bool) – Whether normalization is enabled

  • run_annotate (bool) – Whether annotation is enabled

  • *args – Additional positional arguments passed to Static

  • **kwargs – Additional keyword arguments passed to Static

class SourceSelected[source]

Bases: textual.message.Message

Posted when the source directory is selected via browse button.

Initialize the SourceSelected message.

class FilesSelected[source]

Bases: textual.message.Message

Posted when the user wants to select specific files.

Initialize the FilesSelected message.

class OutputSelected[source]

Bases: textual.message.Message

Posted when the output directory is selected via browse button.

Initialize the OutputSelected message.

class ExtractorChanged(extractor_type)[source]

Bases: textual.message.Message

Posted when the extractor type changes.

extractor_type

The newly selected extractor type

Initialize the ExtractorChanged message.

Parameters:

extractor_type (build_tools.pipeline_tui.core.state.ExtractorType) – The newly selected extractor type

extractor_type
class LanguageChanged(language)[source]

Bases: textual.message.Message

Posted when the language selection changes.

language

The newly selected language code (e.g., “en_US”)

Initialize the LanguageChanged message.

Parameters:

language (str) – The language code

language
class ConstraintsChanged(min_length, max_length, file_pattern)[source]

Bases: textual.message.Message

Posted when syllable length constraints change.

min_length

The new minimum syllable length

max_length

The new maximum syllable length

file_pattern

The file glob pattern

Initialize the ConstraintsChanged message.

Parameters:
  • min_length (int) – Minimum syllable length

  • max_length (int) – Maximum syllable length

  • file_pattern (str) – File glob pattern

min_length
max_length
file_pattern
class PipelineStagesChanged(run_normalize, run_annotate)[source]

Bases: textual.message.Message

Posted when pipeline stage toggles change.

run_normalize

Whether to run normalization

run_annotate

Whether to run annotation

Initialize the PipelineStagesChanged message.

Parameters:
  • run_normalize (bool) – Whether normalization is enabled

  • run_annotate (bool) – Whether annotation is enabled

run_normalize
run_annotate
DEFAULT_CSS = Multiline-String
Show Value
"""
    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;
    }
    """

Default TCSS.

source_path = None
selected_files = []
output_dir = None
extractor_type
language = 'auto'
min_syllable_length = 2
max_syllable_length = 8
file_pattern = '*.txt'
run_normalize = True
run_annotate = True
compose()[source]

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

on_source_browse_pressed(event)[source]

Handle source browse button press.

Posts SourceSelected message to trigger directory browser in parent app. The parent app handles the actual directory selection modal.

Parameters:

event (textual.widgets.Button.Pressed) – Button press event

on_output_browse_pressed(event)[source]

Handle output browse button press.

Posts OutputSelected message to trigger directory browser in parent app.

Parameters:

event (textual.widgets.Button.Pressed) – Button press event

on_select_files_pressed(event)[source]

Handle select files button press.

Posts FilesSelected message to trigger file selector in parent app.

Parameters:

event (textual.widgets.Button.Pressed) – Button press event

on_radio_option_selected(event)[source]

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

Parameters:

event (build_tools.tui_common.controls.RadioOption.Selected) – Radio option selected event

on_input_changed(event)[source]

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

Parameters:

event (textual.widgets.Input.Changed) – Input change event

on_spinner_changed(event)[source]

Handle IntSpinner value changes.

Routes spinner changes to update constraints based on widget_id.

Parameters:

event (build_tools.tui_common.controls.IntSpinner.Changed) – Spinner change event

update_source_path(path)[source]

Update the displayed source path.

Called by parent app after directory selection. Clears any selected files since we’re now using directory mode.

Parameters:

path (pathlib.Path | None) – New source path, or None if cleared

update_output_path(path)[source]

Update the displayed output path.

Called by parent app after directory selection.

Parameters:

path (pathlib.Path | None) – New output path, or None if cleared

update_selected_files(files)[source]

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.

Parameters:

files (list[pathlib.Path]) – List of selected file paths