Skip to content

Commit c5a0b93

Browse files
authored
Merge pull request #1 from brentwg/my-day01-03
My day01 03
2 parents 3ac6cee + 7e850d0 commit c5a0b93

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ------------------------------------------------------------------------
2+
# Helper file for 100 Days of Code
3+
#
4+
# My first 'libaray' code
5+
#
6+
# Brent Gawryluik
7+
# 2018-07-09
8+
# ------------------------------------------------------------------------
9+
10+
11+
def print_header(title):
12+
13+
border_length = len(title) + 12
14+
15+
print()
16+
print_border(border_length)
17+
print_title(title)
18+
print_border(border_length)
19+
print()
20+
21+
def print_border(length):
22+
for _ in range(length):
23+
print('-', end='', flush=True)
24+
25+
print()
26+
27+
28+
def print_title(title):
29+
print(' ', end='', flush=True)
30+
print(title)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ------------------------------------------------------------------------
2+
# 100 Days of Code
3+
# Day 1-3
4+
#
5+
# Pomadaro Timer
6+
# - Playing with Datetimes...
7+
# - or time, anyway...
8+
#
9+
# Brent Gawryluik
10+
# 2018-07-09
11+
# ------------------------------------------------------------------------
12+
13+
import helpers
14+
import progressbar
15+
import time
16+
17+
18+
def main():
19+
helpers.print_header('Pomadaro Timer')
20+
work_duration = get_duration_input("WORK")
21+
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.')
26+
27+
28+
def get_duration_input(activity):
29+
return int(input("Please enter a number for how many minutes you would like to {}: ".format(activity)))
30+
31+
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+
54+
if __name__ == '__main__':
55+
main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
progressbar2

0 commit comments

Comments
 (0)