Tui.Py
None
!! class
TuiKey class
TuiKey source
class TuiKey(pydantic.BaseModel): name: str key: str
!! class
TuiConfig class
TuiConfig source
class TuiConfig(pydantic.BaseModel): new_cmd: List[str] = ["markata", "new", "post"] keymap: List[TuiKey] = [TuiKey(name="new", key="n")]
!! class
Config class
Config source
class Config(pydantic.BaseModel): tui: TuiConfig = TuiConfig()
!! function
config_model function
config_model source
def config_model(markata: "Markata") -> None: markata.config_models.append(Config)
!! function
cli function
cli source
def cli(app, markata): @app.command() def tui(): MarkataApp.run(log="textual.log")
!! class
MarkataWidget class
MarkataWidget source
class MarkataWidget(Widget): def __init__(self, markata: Markata, widget: str = "server") -> None: super().__init__(widget) self.m = markata self.widget = widget self.renderable = getattr(self.m, self.widget) def render(self): return self.renderable async def update(self, renderable: RenderableType) -> None: self.renderable = renderable self.refresh()
!! class
MarkataApp class
MarkataApp source
class MarkataApp(App): async def on_load(self, event): self.m = Markata() self.m.console.quiet = True await self.bind("q", "quit", "quit") await self.bind("r", "refresh", "refresh") self.new_cmd = self.m.config.get("tui", {}).get("new_cmd", "") if self.new_cmd != "": await self.bind("n", "new", "new") async def on_mount(self) -> None: self.server = MarkataWidget(self.m, "server") self.runner = MarkataWidget(self.m, "runner") self.plugins = MarkataWidget(self.m, "plugins") self.summary = MarkataWidget(self.m, "summary") await self.view.dock(Footer(), edge="bottom") await self.view.dock(self.plugins, edge="left", size=30, name="plugins") await self.view.dock(self.summary, edge="right", size=30, name="summary") await self.view.dock(self.server, self.runner, edge="top") self.set_interval(1, self.action_refresh) async def action_refresh(self) -> None: self.refresh() self.runner.refresh() self.server.refresh() self.plugins.refresh() self.summary.refresh() async def action_new(self) -> None: subprocess.Popen( self.new_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
!! function
tui function
tui source
def tui(): MarkataApp.run(log="textual.log")
!! method
init method
init source
def __init__(self, markata: Markata, widget: str = "server") -> None: super().__init__(widget) self.m = markata self.widget = widget self.renderable = getattr(self.m, self.widget) def render(self): return self.renderable async def update(self, renderable: RenderableType) -> None: self.renderable = renderable self.refresh()
!! function
render function
render source
def render(self): return self.renderable