tui.py


MarkataWidget class

None

MarkataWidget source
class MarkataWidget(Widget):
    def __init__(self, markata: Markata, widget: str = "server"):
        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()

MarkataApp class

None

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)

cli function

None

cli source
def cli(app, markata):
    @app.command()
    def tui():
        MarkataApp.run(log="textual.log")

init method

None

init source
def __init__(self, markata: Markata, widget: str = "server"):
        super().__init__(widget)
        self.m = markata
        self.widget = widget
        self.renderable = getattr(self.m, self.widget)

render method

None

render source
def render(self):
        return self.renderable

tui function

None

tui source
def tui():
        MarkataApp.run(log="textual.log")