35 lines
924 B
Python
35 lines
924 B
Python
from textual.app import App, ComposeResult
|
|
from textual.binding import Binding
|
|
from textual.widgets import Footer, Header, Label, ListItem, ListView
|
|
|
|
from main import get_next_ten
|
|
|
|
|
|
class Catlendar(App):
|
|
"""A Textual app to manage stopwatches."""
|
|
|
|
BINDINGS = [
|
|
("d", "toggle_dark", "Toggle dark mode"),
|
|
Binding(key="q", action="quit", description="Quit the app"),
|
|
]
|
|
|
|
def compose(self) -> ComposeResult:
|
|
"""Create child widgets for the app."""
|
|
next_ten = get_next_ten()
|
|
yield Header()
|
|
yield ListView(
|
|
*[ListItem(Label(x)) for x in next_ten]
|
|
)
|
|
yield Footer()
|
|
|
|
def action_toggle_dark(self) -> None:
|
|
"""An action to toggle dark mode."""
|
|
self.theme = (
|
|
"textual-dark" if self.theme == "textual-light" else "textual-light"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = Catlendar()
|
|
app.run()
|