Wip
This commit is contained in:
parent
65ee1e37c6
commit
c40d94a7bd
1 changed files with 45 additions and 3 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
This is where the application is implemented.
|
This is where the application is implemented.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import final, override
|
from typing import Literal, final, override
|
||||||
|
|
||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.containers import Horizontal
|
from textual.containers import Horizontal
|
||||||
|
|
@ -10,6 +10,7 @@ from textual.screen import Screen
|
||||||
from textual.widget import Widget
|
from textual.widget import Widget
|
||||||
from textual.widgets import (
|
from textual.widgets import (
|
||||||
Button,
|
Button,
|
||||||
|
DataTable,
|
||||||
Footer,
|
Footer,
|
||||||
Header,
|
Header,
|
||||||
Input,
|
Input,
|
||||||
|
|
@ -40,8 +41,48 @@ class SearchBar(Widget):
|
||||||
id="teilchen-input",
|
id="teilchen-input",
|
||||||
type="text",
|
type="text",
|
||||||
)
|
)
|
||||||
yield Button("Add", variant="success", id="button-add")
|
yield Button(
|
||||||
yield Button("Search", variant="default", id="button-search")
|
"Add", variant="success", classes="search-bar-buttons", id="button-add"
|
||||||
|
)
|
||||||
|
yield Button(
|
||||||
|
"Search",
|
||||||
|
variant="default",
|
||||||
|
classes="search-bar-buttons",
|
||||||
|
id="button-search",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
TeilchenDatum = tuple[int, str, str, str, str]
|
||||||
|
TeilchenHeader = tuple[
|
||||||
|
Literal["pk"],
|
||||||
|
Literal["Name"],
|
||||||
|
Literal["Description"],
|
||||||
|
Literal["Number"],
|
||||||
|
Literal["Tags"],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
FAKE_DATA: list[TeilchenHeader | TeilchenDatum] = [
|
||||||
|
("pk", "Name", "Description", "Number", "Tags"),
|
||||||
|
(0, "Name0", "Description0", "9000", "#tag0 #tag00 #tag000"),
|
||||||
|
(1, "Name1", "Description1", "9001", "#tag1 #tag11 #tag111"),
|
||||||
|
(2, "Name2", "Description2", "9002", "#tag2 #tag22 #tag222"),
|
||||||
|
(3, "Name3", "Description3", "9003", "#tag3 #tag33 #tag333"),
|
||||||
|
(4, "Name4", "Description4", "9004", "#tag4 #tag44 #tag444"),
|
||||||
|
(5, "Name5", "Description5", "9005", "#tag5 #tag55 #tag555"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@final
|
||||||
|
class SearchResults(Widget):
|
||||||
|
@override
|
||||||
|
def compose(self) -> ComposeResult:
|
||||||
|
yield DataTable(id="table-search-result", cursor_type="row", zebra_stripes=True)
|
||||||
|
|
||||||
|
def on_mount(self) -> None:
|
||||||
|
table: DataTable[None] = self.query_one(DataTable[None])
|
||||||
|
_ = table.add_columns(*FAKE_DATA[0]) # pyright: ignore[reportArgumentType]
|
||||||
|
_ = table.add_rows(FAKE_DATA[1:]) # pyright: ignore[reportArgumentType]
|
||||||
|
|
||||||
|
|
||||||
class AddInventoryScreen(Screen[None]):
|
class AddInventoryScreen(Screen[None]):
|
||||||
|
|
@ -49,6 +90,7 @@ class AddInventoryScreen(Screen[None]):
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header()
|
yield Header()
|
||||||
yield SearchBar()
|
yield SearchBar()
|
||||||
|
yield SearchResults()
|
||||||
yield Footer()
|
yield Footer()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue