mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
snapshot
This commit is contained in:
@@ -11,13 +11,14 @@ class IndeterminateProgressBar(App[None]):
|
||||
"""Timer to simulate progress happening."""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
self.time = 0
|
||||
with Center():
|
||||
with Middle():
|
||||
yield ProgressBar()
|
||||
yield ProgressBar(_get_time=lambda: self.time)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
"""Set up a timer to simulate progess happening."""
|
||||
"""Set up a timer to simulate progress happening."""
|
||||
self.progress_timer = self.set_interval(1 / 10, self.make_progress, pause=True)
|
||||
|
||||
def make_progress(self) -> None:
|
||||
@@ -31,14 +32,18 @@ class IndeterminateProgressBar(App[None]):
|
||||
|
||||
def key_f(self) -> None:
|
||||
# Freeze time for the indeterminate progress bar.
|
||||
self.query_one(ProgressBar).query_one("#bar")._get_elapsed_time = lambda: 5
|
||||
self.time = 5
|
||||
self.refresh()
|
||||
|
||||
def key_t(self) -> None:
|
||||
# Freeze time to show always the same ETA.
|
||||
self.query_one(ProgressBar).query_one("#eta")._get_elapsed_time = lambda: 3.9
|
||||
self.query_one(ProgressBar).update(total=100, progress=39)
|
||||
self.time = 0
|
||||
self.query_one(ProgressBar).update(total=100, progress=0)
|
||||
self.time = 3.9
|
||||
self.query_one(ProgressBar).update(progress=39)
|
||||
|
||||
def key_u(self) -> None:
|
||||
self.refresh()
|
||||
self.query_one(ProgressBar).update(total=100, progress=100)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user