mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.clock import MockClock
|
||||
from textual.containers import Center, Middle
|
||||
from textual.timer import Timer
|
||||
from textual.widgets import Footer, ProgressBar
|
||||
@@ -11,10 +12,10 @@ class IndeterminateProgressBar(App[None]):
|
||||
"""Timer to simulate progress happening."""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
self.time = 0
|
||||
self.clock = MockClock()
|
||||
with Center():
|
||||
with Middle():
|
||||
yield ProgressBar(_get_time=lambda: self.time)
|
||||
yield ProgressBar(clock=self.clock)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
@@ -32,14 +33,14 @@ class IndeterminateProgressBar(App[None]):
|
||||
|
||||
def key_f(self) -> None:
|
||||
# Freeze time for the indeterminate progress bar.
|
||||
self.time = 5
|
||||
self.clock.set_time(5)
|
||||
self.refresh()
|
||||
|
||||
def key_t(self) -> None:
|
||||
# Freeze time to show always the same ETA.
|
||||
self.time = 0
|
||||
self.clock.set_time(0)
|
||||
self.query_one(ProgressBar).update(total=100, progress=0)
|
||||
self.time = 3.9
|
||||
self.clock.set_time(3.9)
|
||||
self.query_one(ProgressBar).update(progress=39)
|
||||
|
||||
def key_u(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user