Change progress bar text when completing 100% #2353
-
In this example the total progress is 5 seconds (I'm building a model that can be malleable, that I can use any amount of total seconds that will work the same):
Output (same line): But the output I wanted does not contain this I think it would be interesting to have an option where we can already set the text while it's in progress and set the text when it completes the progress. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This would be the expected behaviour. When you advance to 100%, you sleep a total of 2 seconds before setting the description. If you want to change the description text, you should do it as soon as the task is finished. Try this: from rich.progress import Progress
import time
import sys
def main(timeout):
start_time = time.time()
penultimate_quarter = timeout-1
with Progress() as progress:
task1 = progress.add_task("[green]Processing...", total=100)
time.sleep(1)
while not progress.finished:
time.sleep(1)
progress.update(task1, advance=100/penultimate_quarter)
progress.update(task1, description="[blue]Complete Task", advance=100)
print("--- %s seconds ---" % (time.time() - start_time))
if __name__ == "__main__":
main(5) |
Beta Was this translation helpful? Give feedback.
This would be the expected behaviour. When you advance to 100%, you sleep a total of 2 seconds before setting the description. If you want to change the description text, you should do it as soon as the task is finished.
Try this: