introduction text

This commit is contained in:
Will McGugan
2022-08-23 11:25:03 +01:00
parent b7b32f0429
commit b24c7a8f34
9 changed files with 70 additions and 28 deletions

View File

@@ -69,13 +69,7 @@ class Stopwatch(Static):
class StopwatchApp(App):
"""Manage the timers."""
def on_load(self) -> None:
"""Called when the app first loads."""
self.bind("a", "add_stopwatch", description="Add")
self.bind("r", "remove_stopwatch", description="Remove")
self.bind("d", "toggle_dark", description="Dark mode")
"""A Textual app to manage stopwatches."""
def compose(self) -> ComposeResult:
"""Called to ad widgets to the app."""
@@ -83,6 +77,12 @@ class StopwatchApp(App):
yield Footer()
yield Container(Stopwatch(), Stopwatch(), Stopwatch(), id="timers")
def on_load(self) -> None:
"""Called when the app first loads."""
self.bind("d", "toggle_dark", description="Dark mode")
self.bind("a", "add_stopwatch", description="Add")
self.bind("r", "remove_stopwatch", description="Remove")
def action_add_stopwatch(self) -> None:
"""An action to add a timer."""
new_stopwatch = Stopwatch()
@@ -91,7 +91,7 @@ class StopwatchApp(App):
def action_remove_stopwatch(self) -> None:
"""Called to remove a timer."""
timers = self.query("#timers Stopwatch")
timers = self.query("Stopwatch")
if timers:
timers.last().remove()

View File

@@ -10,7 +10,7 @@ class TimeDisplay(Static):
"""A widget to display elapsed time."""
start_time = Reactive(monotonic)
time = Reactive(0.0)
time = Reactive.init(0.0)
def on_mount(self) -> None:
"""Event handler called when widget is added to the app."""

View File

@@ -10,7 +10,7 @@ class TimeDisplay(Static):
"""A widget to display elapsed time."""
start_time = Reactive(monotonic)
time = Reactive(0.0)
time = Reactive.init(0.0)
total = Reactive(0.0)
def on_mount(self) -> None: