mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
introduction text
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user