from textual.app import App from .db import db from .kimaiapi import KimaiAPI from .screens.hamster import HamsterScreen from .screens.kimai import KimaiScreen class HamsterToolsApp(App): CSS_PATH = "app.tcss" BINDINGS = [ ("h", "switch_mode('hamster')", "Hamster"), ("k", "switch_mode('kimai')", "Kimai"), ("q", "quit", "Quit"), ] api_ = None @property def api(self) -> KimaiAPI: if self.api_ is None: self.api_ = KimaiAPI() return self.api_ def __init__(self): self.MODES = { "hamster": HamsterScreen(), "kimai": KimaiScreen(), } super().__init__() def on_mount(self) -> None: self.switch_mode("hamster") def action_quit(self) -> None: db.close() self.exit()