How do I use a progress bar when my script is doing some task that is likely to take time?
For example, a function which takes some time to complete and returns
You can also use enlighten. The main advantage is you can log at the same time without overwriting your progress bar.
import time
import enlighten
manager = enlighten.Manager()
pbar = manager.counter(total=100)
for num in range(1, 101):
time.sleep(0.05)
print('Step %d complete' % num)
pbar.update()
It also handles multiple progress bars.
import time
import enlighten
manager = enlighten.Manager()
odds = manager.counter(total=50)
evens = manager.counter(total=50)
for num in range(1, 101):
time.sleep(0.05)
if num % 2:
odds.update()
else:
evens.update()