64 lines
1.5 KiB
Python
64 lines
1.5 KiB
Python
|
|
"""
|
||
|
|
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()
|