Skip to content

Instantly share code, notes, and snippets.

@brando90
Created August 13, 2021 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brando90/3304119120841b1ebf892fe93a2cc3c9 to your computer and use it in GitHub Desktop.
Save brando90/3304119120841b1ebf892fe93a2cc3c9 to your computer and use it in GitHub Desktop.
having_the_progress_bar_show_its_done_properly
"""
Use this one to make sure the "end" is shown properly 100% etc
"""
import time
import progressbar
widgets = [
progressbar.Percentage(),
progressbar.Bar(),
' ', progressbar.SimpleProgress(),
' ', progressbar.ETA(),
' ', progressbar.AdaptiveTransferSpeed(unit='it'),
]
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar(range(100)):
time.sleep(0.1)
bar.update(i)
"""
19%|########## | 19 of 100 ETA: 0:00:17 4.9 it/s
when done:
100%|####################################| 100 of 100 Time: 0:00:20 4.9 it/s
"""
@brando90
Copy link
Author

the key is to wrap the iterator (of fixed length) using bar e.g. bar(range(100))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment