24 lines
759 B
Python
24 lines
759 B
Python
from textual.app import ComposeResult
|
|
from textual.containers import VerticalScroll
|
|
from textual.screen import Screen
|
|
from textual.widgets import DataTable, Header, Footer
|
|
|
|
from hamstertools.db import ClockifyProject
|
|
|
|
|
|
class ClockifyProjectScreen(Screen):
|
|
"""Screen for listing Clockify projects"""
|
|
|
|
BINDINGS = [("q", "quit", "Quit")]
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Header()
|
|
yield VerticalScroll(DataTable())
|
|
yield Footer()
|
|
|
|
def on_mount(self) -> None:
|
|
table = self.query_one(DataTable)
|
|
table.add_columns("ID", "Name", "Workspace ID")
|
|
|
|
for project in ClockifyProject.select():
|
|
table.add_row(project.clockify_id, project.name, project.workspace_id) |