2021-10-04 07:22:15 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
|
|
import random
|
|
|
|
import time
|
|
|
|
|
2023-08-03 14:40:14 +00:00
|
|
|
from progress.bar import Bar, ChargingBar, FillingCirclesBar, FillingSquaresBar, IncrementalBar, PixelBar, ShadyBar
|
|
|
|
from progress.counter import Countdown, Counter, Pie, Stack
|
|
|
|
from progress.spinner import LineSpinner, MoonSpinner, PieSpinner, PixelSpinner, Spinner
|
2021-10-04 07:22:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def sleep():
|
|
|
|
t = 0.01
|
|
|
|
t += t * random.uniform(-0.1, 0.1) # Add some variance
|
|
|
|
time.sleep(t)
|
|
|
|
|
|
|
|
|
|
|
|
for bar_cls in (Bar, ChargingBar, FillingSquaresBar, FillingCirclesBar):
|
2023-08-03 14:40:14 +00:00
|
|
|
suffix = "%(index)d/%(max)d [%(elapsed)d / %(eta)d / %(eta_td)s]"
|
2021-10-04 07:22:15 +00:00
|
|
|
bar = bar_cls(bar_cls.__name__, suffix=suffix)
|
2023-08-03 14:40:14 +00:00
|
|
|
for _i in bar.iter(range(200)):
|
2021-10-04 07:22:15 +00:00
|
|
|
sleep()
|
|
|
|
|
|
|
|
for bar_cls in (IncrementalBar, PixelBar, ShadyBar):
|
2023-08-03 14:40:14 +00:00
|
|
|
suffix = "%(percent)d%% [%(elapsed_td)s / %(eta)d / %(eta_td)s]"
|
2021-10-04 07:22:15 +00:00
|
|
|
bar = bar_cls(bar_cls.__name__, suffix=suffix)
|
2023-08-03 14:40:14 +00:00
|
|
|
for _i in bar.iter(range(200)):
|
2021-10-04 07:22:15 +00:00
|
|
|
sleep()
|
|
|
|
|
|
|
|
for spin in (Spinner, PieSpinner, MoonSpinner, LineSpinner, PixelSpinner):
|
2023-08-03 14:40:14 +00:00
|
|
|
for _i in spin(spin.__name__ + " ").iter(range(100)):
|
2021-10-04 07:22:15 +00:00
|
|
|
sleep()
|
|
|
|
print()
|
|
|
|
|
|
|
|
for singleton in (Counter, Countdown, Stack, Pie):
|
2023-08-03 14:40:14 +00:00
|
|
|
for _i in singleton(singleton.__name__ + " ").iter(range(100)):
|
2021-10-04 07:22:15 +00:00
|
|
|
sleep()
|
|
|
|
print()
|
|
|
|
|
2023-08-03 14:40:14 +00:00
|
|
|
bar = IncrementalBar("Random", suffix="%(index)d")
|
|
|
|
for _i in range(100):
|
2021-10-04 07:22:15 +00:00
|
|
|
bar.goto(random.randint(0, 100))
|
|
|
|
sleep()
|
|
|
|
bar.finish()
|