feat(ui): ✨ Display header, footer, and searchbar
This commit is contained in:
parent
de8c467d7f
commit
65ee1e37c6
2 changed files with 71 additions and 0 deletions
8
src/teilchensammler_cli/__init__.py
Normal file
8
src/teilchensammler_cli/__init__.py
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
"""
|
||||||
|
This file exists so the directory becomes a package.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .main import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
63
src/teilchensammler_cli/main.py
Normal file
63
src/teilchensammler_cli/main.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue