Skip to content

Commit 376ccfd

Browse files
committed
added Pomodoro App
1 parent e5e4cef commit 376ccfd

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed
Loading

Pomodoro App/Images/pomodoro.gif

1.01 MB
Loading

Pomodoro App/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
**Pomodoro Timer App**
2+
3+
**GOAL**
4+
The Goal of this game is to create a Pomodoro Timer App.
5+
6+
**DESCRIPTION**
7+
The Pomodoro Technique is a time management method based on 25-minute stretches of focused work broken by five-minute breaks. Longer breaks, typically 15 to 30 minutes, are taken after four consecutive work intervals. Each work interval is called a pomodoro, the Italian word for tomato (plural: pomodori). That is the reason of the Tomato Theme of this app.
8+
9+
### LIBRARIES NEEDED
10+
11+
1. Tkinter: It is a inbuilt python library which provides useful GUI functionalities.
12+
13+
**WHAT I HAD DONE**
14+
Used Tkinter GUI library to make UI for the App, and created logic to simulate a Pomodoro timer. Set the Work time and start the timer. The timer automatically enters break mode after timer ends. Declared reps to denote the repetitions for short breaks and long breaks.
15+
16+
### DEMONSTRATION
17+
https://drive.google.com/drive/folders/11TlXrD15NZ7n3xb8kfkdHJexSGMeNJai?usp=share_link
18+
19+
### Sarthak Joleya ###

Pomodoro App/index.py

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
from tkinter import *
2+
3+
# ---------------------------- CONSTANTS ------------------------------- #
4+
PINK = "#e2979c"
5+
RED = "#e7305b"
6+
GREEN = "#9bdeac"
7+
YELLOW = "#f7f5dd"
8+
FONT_NAME = "Courier"
9+
WORK_MIN = 25
10+
SHORT_BREAK_MIN = 5
11+
LONG_BREAK_MIN = 20
12+
reps = 0
13+
timer = None
14+
15+
# ---------------------------- TIMER RESET ------------------------------- #
16+
17+
def reset_timer():
18+
window.after_cancel(timer)
19+
canvas.itemconfig(timer_text, text="00:00")
20+
title_label.config(text="Timer")
21+
check_marks.config(text="")
22+
global reps
23+
reps = 0
24+
25+
# ---------------------------- TIMER MECHANISM ------------------------------- #
26+
27+
def start_timer():
28+
global reps
29+
reps = reps + 1
30+
31+
work_sec = WORK_MIN * 60
32+
short_break_sec = SHORT_BREAK_MIN * 60
33+
long_break_sec = LONG_BREAK_MIN * 60
34+
35+
if reps % 8 == 0:
36+
count_down(long_break_sec)
37+
title_label.config(text="Break", fg=RED)
38+
elif reps % 2 == 0:
39+
count_down(short_break_sec)
40+
title_label.config(text="Break", fg=PINK)
41+
else:
42+
count_down(work_sec)
43+
title_label.config(text="Work", fg=GREEN)
44+
45+
46+
# ---------------------------- COUNTDOWN MECHANISM ------------------------------- #
47+
def count_down(count):
48+
49+
count_min = count // 60
50+
count_sec = count % 60
51+
if count_sec < 10:
52+
count_sec = f"0{count_sec}"
53+
54+
canvas.itemconfig(timer_text, text=f"{count_min}:{count_sec}")
55+
if count > 0:
56+
global timer
57+
timer = window.after(1000, count_down, count - 1)
58+
else:
59+
start_timer()
60+
marks = ""
61+
work_sessions = reps // 2
62+
for _ in range(work_sessions):
63+
marks += "✔"
64+
check_marks.config(text=marks)
65+
66+
67+
# ---------------------------- UI SETUP ------------------------------- #
68+
window = Tk()
69+
window.title("Pomodoro")
70+
window.config(padx=100, pady=50, bg=YELLOW)
71+
72+
title_label = Label(text="Timer", fg=GREEN, bg=YELLOW, font=(FONT_NAME, 50))
73+
title_label.grid(column=1, row=0)
74+
75+
canvas = Canvas(width=200, height=224, bg=YELLOW, highlightthickness=0)
76+
tomato_img = PhotoImage(file="resources/tomato.png")
77+
canvas.create_image(100, 112, image=tomato_img)
78+
timer_text = canvas.create_text(100, 130, text="00:00", fill="white", font=(FONT_NAME, 35, "bold"))
79+
canvas.grid(column=1, row=1)
80+
81+
start_button = Button(text="Start", highlightthickness=0, command=start_timer)
82+
start_button.grid(column=0, row=2)
83+
84+
reset_button = Button(text="Reset", highlightthickness=0, command=reset_timer)
85+
reset_button.grid(column=2, row=2)
86+
87+
check_marks = Label(fg=GREEN, bg=YELLOW)
88+
check_marks.grid(column=1, row=3)
89+
90+
window.mainloop()

Pomodoro App/resources/tomato.png

10.5 KB
Loading

0 commit comments

Comments
 (0)