43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from textual.app import ComposeResult
|
|
from textual.screen import Screen
|
|
from textual.widgets import (
|
|
Header,
|
|
Footer,
|
|
TabbedContent,
|
|
TabPane,
|
|
)
|
|
|
|
from .activities import ActivityList
|
|
from .categories import CategoryList
|
|
from .tags import TagList
|
|
|
|
|
|
class HamsterScreen(Screen):
|
|
BINDINGS = [
|
|
("c", "show_tab('categories')", "Categories"),
|
|
("a", "show_tab('activities')", "Activities"),
|
|
("t", "show_tab('tags')", "Tags"),
|
|
]
|
|
|
|
SUB_TITLE = "Hamster"
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Header()
|
|
with TabbedContent(initial="activities"):
|
|
with TabPane("Categories", id="categories"):
|
|
yield CategoryList()
|
|
with TabPane("Activities", id="activities"):
|
|
yield ActivityList()
|
|
with TabPane("Tags", id="tags"):
|
|
yield TagList()
|
|
yield Footer()
|
|
|
|
def on_mount(self) -> None:
|
|
self.query_one("TabbedContent Tabs").can_focus = False
|
|
self.query_one("#activities DataTable").focus()
|
|
|
|
def action_show_tab(self, tab: str) -> None:
|
|
"""Switch to a new tab."""
|
|
self.get_child_by_type(TabbedContent).active = tab
|
|
self.query_one(f"#{tab} DataTable").focus()
|