mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
screenshor plugin fix
This commit is contained in:
@@ -12,18 +12,19 @@ class TimeDisplay(Static):
|
||||
start_time = Reactive(monotonic)
|
||||
time = Reactive(0.0)
|
||||
|
||||
def watch_time(self, time: float) -> None:
|
||||
"""Called when the time attribute changes."""
|
||||
minutes, seconds = divmod(time - self.start_time, 60)
|
||||
hours, minutes = divmod(minutes, 60)
|
||||
self.update(f"{hours:02,.0f}:{minutes:02.0f}:{seconds:05.2f}")
|
||||
|
||||
def on_mount(self) -> None:
|
||||
"""Event handler called when widget is added to the app."""
|
||||
self.set_interval(1 / 30, self.update_time)
|
||||
self.set_interval(1 / 60, self.update_time)
|
||||
|
||||
def update_time(self) -> None:
|
||||
self.time = monotonic()
|
||||
"""Method to update the time to the current time."""
|
||||
self.time = monotonic() - self.start_time
|
||||
|
||||
def watch_time(self, time: float) -> None:
|
||||
"""Called when the time attribute changes."""
|
||||
minutes, seconds = divmod(time, 60)
|
||||
hours, minutes = divmod(minutes, 60)
|
||||
self.update(f"{hours:02,.0f}:{minutes:02.0f}:{seconds:05.2f}")
|
||||
|
||||
|
||||
class Stopwatch(Static):
|
||||
@@ -41,7 +42,7 @@ class Stopwatch(Static):
|
||||
yield Button("Start", id="start", variant="success")
|
||||
yield Button("Stop", id="stop", variant="error")
|
||||
yield Button("Reset", id="reset")
|
||||
yield TimeDisplay("00:00:00.00")
|
||||
yield TimeDisplay()
|
||||
|
||||
|
||||
class StopwatchApp(App):
|
||||
|
||||
Reference in New Issue
Block a user