-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathcurrent_time.py
More file actions
29 lines (20 loc) · 878 Bytes
/
Copy pathcurrent_time.py
File metadata and controls
29 lines (20 loc) · 878 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
"""``CurrentTime`` displays the current date and time, updated live.
Reach for it to stamp log-like output with a wall clock, independent of
the bar's own progress -- unlike ``Timer``, which reports time elapsed
*since the bar started* rather than the actual time of day.
This example runs longer than most in this set: the clock is only shown
to whole-second resolution, so a bar that finishes in a fraction of a
second would show the same, unmoving reading for its entire run --
"updated live" would never actually be visible.
"""
import time
import progressbar
STEPS = 24
def main() -> None:
widgets = [progressbar.CurrentTime(), ' ', progressbar.Bar()]
with progressbar.ProgressBar(max_value=STEPS, widgets=widgets) as bar:
for step in range(STEPS):
bar.update(step + 1)
time.sleep(0.3)
if __name__ == '__main__':
main()