File tree Expand file tree Collapse file tree 3 files changed +86
-0
lines changed
days/01-03-datetimes/my_code Expand file tree Collapse file tree 3 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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 ()
Original file line number Diff line number Diff line change
1
+ progressbar2
You can’t perform that action at this time.
0 commit comments