-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathtimer.py
More file actions
30 lines (21 loc) · 927 Bytes
/
Copy pathtimer.py
File metadata and controls
30 lines (21 loc) · 927 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
"""``Timer`` displays the elapsed time since the bar started.
Reach for it whenever "how long has this taken so far" matters more
than an estimate of what remains -- unlike the ``ETA`` family, it needs
no ``max_value`` and works just as well for indeterminate work. Compare
``CurrentTime`` for the wall-clock time of day instead of a duration.
This example runs longer than most in this set: elapsed time is only shown
to whole-second resolution, so a bar that finishes in a few milliseconds
would read "Elapsed Time: 0:00:00" for its entire run -- the one thing this
widget exists to show would never move.
"""
import time
import progressbar
STEPS = 24
def main() -> None:
widgets = [progressbar.Timer()]
with progressbar.ProgressBar(max_value=STEPS, widgets=widgets) as bar:
for step in range(STEPS):
bar.update(step + 1)
time.sleep(0.2)
if __name__ == '__main__':
main()