-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathtqdm_style.py
More file actions
40 lines (32 loc) · 973 Bytes
/
Copy pathtqdm_style.py
File metadata and controls
40 lines (32 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Keep tqdm's keyword style when you switch to progressbar.
Coming from `tqdm`, these keywords mean the same thing here: `desc` becomes
the prefix and `total` becomes `max_value` on any `ProgressBar`. `unit=`/
`unit_scale=` only show up through a widget that reads them, such as
`UnitProgress`, so this lists one explicitly alongside `Postfix` for the
live per-file status.
"""
import time
import progressbar
STEPS = 24
def main() -> None:
widgets = [
progressbar.Percentage(),
' ',
progressbar.Bar(),
' ',
progressbar.UnitProgress(),
' ',
progressbar.Postfix(),
]
with progressbar.ProgressBar(
desc='Downloading',
total=STEPS,
unit='files',
widgets=widgets,
postfix='starting',
) as bar:
for step in range(STEPS):
bar.update(step + 1, postfix=f'file {step + 1}')
time.sleep(0.005)
if __name__ == '__main__':
main()