Skip to content

Finding

sereto.tui.finding

InputWithLabel

Bases: Widget

An input with a label.

Source code in sereto/tui/finding.py
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class InputWithLabel(Widget):
    """An input with a label."""

    DEFAULT_CSS = """
    InputWithLabel {
        layout: horizontal;
        height: auto;
    }
    InputWithLabel Label {
        padding: 1;
        width: 12;
        text-align: right;
    }
    InputWithLabel Input {
        width: 1fr;
    }
    """

    def __init__(self, input_label: str, value: str | None = None, id: str | None = None) -> None:
        super().__init__(id=id)
        self.input_label = input_label
        self.value = value

    def compose(self) -> ComposeResult:
        yield Label(self.input_label)
        yield Input(value=self.value)

SelectWithLabel

Bases: Generic[T], Widget

A select with a label.

Source code in sereto/tui/finding.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
class SelectWithLabel(Generic[T], Widget):
    """A select with a label."""

    DEFAULT_CSS = """
    SelectWithLabel {
        layout: horizontal;
        height: auto;
    }
    SelectWithLabel Label {
        padding: 1;
        width: 12;
        text-align: right;
    }
    SelectWithLabel Input {
        width: 1fr;
    }
    """

    def __init__(
        self, options: Iterable[tuple[RenderableType, T]], label: str, id: str | None = None, allow_blank: bool = True
    ) -> None:
        super().__init__(id=id)
        self.options = options
        self.label = label
        self.allow_blank = allow_blank

    def compose(self) -> ComposeResult:
        yield Label(self.label)
        yield Select(options=self.options, allow_blank=self.allow_blank)

SeretoApp

Bases: App[None]

A SeReTo Textual CLI interface.

Source code in sereto/tui/finding.py
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
class SeretoApp(App[None]):
    """A SeReTo Textual CLI interface."""

    CSS_PATH = "finding.tcss"
    TITLE = "SeReTo"
    SUB_TITLE = "Security Reporting Tool"
    BINDINGS = [("/", "focus_search", "Focus on search")]

    def __init__(
        self,
        #  settings: Settings,
        project: Project,
        categories: list[str],
    ) -> None:
        super().__init__()
        # self.settings = settings
        self.project = project
        self.categories = categories

    def compose(self) -> ComposeResult:
        """Add widgets to the app."""
        yield Header()
        yield SearchWidget(id="search")
        yield ResultsWidget(id="results")
        yield Footer()

    def action_focus_search(self) -> None:
        """Focus on the search input field."""
        self.query_one("#search", SearchWidget).input_field.focus()

Focus on the search input field.

Source code in sereto/tui/finding.py
333
334
335
def action_focus_search(self) -> None:
    """Focus on the search input field."""
    self.query_one("#search", SearchWidget).input_field.focus()

compose()

Add widgets to the app.

Source code in sereto/tui/finding.py
326
327
328
329
330
331
def compose(self) -> ComposeResult:
    """Add widgets to the app."""
    yield Header()
    yield SearchWidget(id="search")
    yield ResultsWidget(id="results")
    yield Footer()