Skip to content

Commit 7e850d0

Browse files
committed
Add functions for timing and displaying tasks
1 parent f326ae6 commit 7e850d0

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

days/01-03-datetimes/my_code/program.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,52 @@
44
#
55
# Pomadaro Timer
66
# - Playing with Datetimes...
7+
# - or time, anyway...
78
#
89
# Brent Gawryluik
910
# 2018-07-09
1011
# ------------------------------------------------------------------------
1112

1213
import helpers
14+
import progressbar
15+
import time
1316

1417

1518
def main():
1619
helpers.print_header('Pomadaro Timer')
1720
work_duration = get_duration_input("WORK")
1821
rest_duration = get_duration_input("REST")
22+
display_timer(work_duration, 'WORK')
23+
display_timer(rest_duration, 'REST')
24+
print()
25+
print('Exiting the Pomadaro timer process.')
1926

2027

2128
def get_duration_input(activity):
22-
return input("Please enter for how many minutes you would like to {}: ".format(activity))
29+
return int(input("Please enter a number for how many minutes you would like to {}: ".format(activity)))
2330

2431

32+
def display_timer(duration, activity):
33+
34+
print()
35+
print("Starting new {} task".format(activity))
36+
37+
if duration == 1:
38+
print("Now displaying {} timer for {} minute...".format(activity, duration))
39+
elif duration > 1:
40+
print("Now displaying {} timer for {} minutes...".format(activity, duration))
41+
42+
print ()
43+
44+
bar = progressbar.ProgressBar(widgets=[
45+
progressbar.Bar(),
46+
])
47+
48+
for i in bar(range(duration *60)):
49+
time.sleep(1)
50+
51+
print()
52+
print("{} task is done".format(activity))
53+
2554
if __name__ == '__main__':
2655
main()

0 commit comments

Comments
 (0)