From 65ee1e37c65c156135eb30cbdbcc8f14d0c2ccf5 Mon Sep 17 00:00:00 2001 From: bronsen Date: Thu, 4 Dec 2025 13:21:49 +0100 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E2=9C=A8=20Display=20header,=20foo?= =?UTF-8?q?ter,=20and=20searchbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/teilchensammler_cli/__init__.py | 8 ++++ src/teilchensammler_cli/main.py | 63 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/teilchensammler_cli/__init__.py create mode 100644 src/teilchensammler_cli/main.py diff --git a/src/teilchensammler_cli/__init__.py b/src/teilchensammler_cli/__init__.py new file mode 100644 index 0000000..18235ac --- /dev/null +++ b/src/teilchensammler_cli/__init__.py @@ -0,0 +1,8 @@ +""" +This file exists so the directory becomes a package. +""" + +from .main import main + +if __name__ == "__main__": + main() diff --git a/src/teilchensammler_cli/main.py b/src/teilchensammler_cli/main.py new file mode 100644 index 0000000..3ca3a9b --- /dev/null +++ b/src/teilchensammler_cli/main.py @@ -0,0 +1,63 @@ +""" +This is where the application is implemented. +""" + +from typing import final, override + +from textual.app import App, ComposeResult +from textual.containers import Horizontal +from textual.screen import Screen +from textual.widget import Widget +from textual.widgets import ( + Button, + Footer, + Header, + Input, +) + + +@final +class SearchBar(Widget): + DEFAULT_CSS = """ + #teilchen-input { + width: 4fr; + } + #button-search, #button-add { + width: 1fr; + } + """ + + @override + def compose(self) -> ComposeResult: + with Horizontal(id="search-bar-widget"): + yield Input( + placeholder="Enter Teilchen information: name, description, #tags", + tooltip=( + "This is a free-form field: Enter a name and " + "description any way you like. You should use #hashtags for any " + "meta information." + ), + id="teilchen-input", + type="text", + ) + yield Button("Add", variant="success", id="button-add") + yield Button("Search", variant="default", id="button-search") + + +class AddInventoryScreen(Screen[None]): + @override + def compose(self) -> ComposeResult: + yield Header() + yield SearchBar() + yield Footer() + + +@final +class SammlerApp(App[None]): + def on_mount(self) -> None: + _ = self.push_screen(AddInventoryScreen()) + + +def main() -> None: + app = SammlerApp() + app.run()