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()