This commit is contained in:
Waylon Walker 2023-06-14 13:43:06 -05:00
parent 892a3c9a8a
commit 3f28a10b16
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
5 changed files with 98 additions and 111 deletions

View file

@ -2,9 +2,9 @@ from textual.app import App, ComposeResult
from textual.containers import ScrollableContainer
from textual.widgets import Footer, Header, Static
import typer
from websocket import create_connection
from learn_sql_model.cli.common import verbose_callback
from learn_sql_model.models.hero import Heros
dashboard_app = typer.Typer()
@ -24,16 +24,8 @@ class HeroName(Static):
"""A stopwatch widget."""
class DashboardApp(App):
"""A Textual app to manage stopwatches."""
BINDINGS = [("d", "toggle_dark", "Toggle dark mode")]
def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
yield Header()
yield Footer()
yield ScrollableContainer(*[HeroName(hero.name) for hero in Heros.list().heros])
class HerosDisplay(Static):
"""A stopwatch widget."""
@property
def ws(self):
@ -48,6 +40,24 @@ class DashboardApp(App):
connect()
return self._ws
def compose(self) -> ComposeResult:
"""Create child widgets of a stopwatch."""
for hero in self.heros:
yield HeroName(hero.name)
class DashboardApp(App):
"""A Textual app to manage stopwatches."""
BINDINGS = [("d", "toggle_dark", "Toggle dark mode")]
# heros = reactive(Heros.list())
def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
yield Header()
yield Footer()
yield ScrollableContainer(HerosDisplay())
def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark