Replies: 2 comments
-
This is very unlikely the right way to do this ... but it's possible to progress = Progress(
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TaskProgressColumn(),
TimeRemainingColumn(),
)
with progress:
task = progress.add_task("Processing", total=10)
await self.mount(Static(progress, id="progress-bar"))
while not progress.finished:
await sleep(0.5)
progress.update(task, advance=1)
self.query_one("#progress-bar").update(progress) This is likely bad practice though, and I'll update the above once I've learnt more about reactivity in Textual. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yesterday I was also playing around with progress bars in Textual and I did a similar thing to create an indeterminate progress bar: 2022-11-23.11-38-45.mp4Here is the code for the full app: from rich.progress import Progress, BarColumn
from textual.app import App, ComposeResult
from textual.widgets import Static
class IndeterminateProgress(Static):
def __init__(self):
super().__init__("")
self._bar = Progress(BarColumn()) # Create the `Progress` object with just the column for the bar
self._bar.add_task("", total=None) # Add an indeterminate task.
def on_mount(self) -> None:
# When the widget is mounted start updating the display regularly.
self.update_render = self.set_interval(1 / 60, self.update_progress_bar)
def update_progress_bar(self) -> None:
self.update(self._bar)
class MyApp(App):
def compose(self) -> ComposeResult:
yield IndeterminateProgress()
if __name__ == "__main__":
app = MyApp()
app.run() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to add live progress to textual
Widget
?Beta Was this translation helpful? Give feedback.
All reactions