Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0dd11a8

Browse files
author
Harshit Kr Vishwakarma
committedOct 26, 2021
Pomodoro App in Python
<img src="https://i.imgur.com/4Ch1OYr.jpg"> ```bash cd Pomodoro-App python3 main.py ``` 1. Hit the start button and timer will begin. 2. After 25 minutes one rep will be complete and timer for break will begin. 3. After break of 10 minutes again timer for work will start. 4. After 4 reps of work and break then you will be greeted with well done message on the screen. 5. Each rep is shown by the tick mark (✅). 6. To stop and reset the timer simply hit reset. ![Start](https://i.imgur.com/LDstdPS.png) ![Break](https://i.imgur.com/Pp0hx8X.png) ![Well Done](https://i.imgur.com/iyYIDZX.png)
1 parent d747f96 commit 0dd11a8

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed
 

‎Pomodoro-App/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Pomodoro App in Python
2+
3+
## About Pomodoro
4+
Pomodoro is Italian for tomato. 🍅) <br>
5+
This popular time management method asks you to alternate pomodoros — focused work sessions — with frequent short breaks to promote sustained concentration and stave off mental fatigue.
6+
7+
## Pomodoro Technique
8+
<img src="https://i.imgur.com/4Ch1OYr.jpg">
9+
10+
## Running the app
11+
```bash
12+
cd Pomodoro-App
13+
python3 main.py
14+
```
15+
16+
# How the app works
17+
1. Hit the start button and timer will begin.
18+
2. After 25 minutes one rep will be complete and timer for break will begin.
19+
3. After break of 10 minutes again timer for work will start.
20+
4. After 4 reps of work and break then you will be greeted with well done message on the screen.
21+
5. Each rep is shown by the tick mark (✅).
22+
6. To stop and reset the timer simply hit reset.
23+
24+
## Screenshots of the app
25+
26+
### Work
27+
![Start](https://i.imgur.com/LDstdPS.png)
28+
### Break
29+
![Break](https://i.imgur.com/Pp0hx8X.png)
30+
### Well Done
31+
![Well Done](https://i.imgur.com/iyYIDZX.png)

‎Pomodoro-App/main.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
from tkinter import *
2+
import math
3+
4+
# ---------------------------- CONSTANTS ------------------------------- #
5+
PINK = "#e2979c"
6+
RED = "#e7305b"
7+
GREEN = "#9bdeac"
8+
YELLOW = "#f7f5dd"
9+
FONT_NAME = "Courier"
10+
11+
# set work time in min
12+
WORK_MIN = 25
13+
14+
# set break time in min
15+
SHORT_BREAK_MIN = 10
16+
17+
# set long break time in min
18+
LONG_BREAK_MIN = 20
19+
reps = 0
20+
check = ""
21+
timer = None
22+
# ---------------------------- TIMER RESET ------------------------------- #
23+
24+
def on_reset(count="00:00"):
25+
global reps, check
26+
reps = 0
27+
check = ""
28+
29+
window.after_cancel(timer)
30+
label.config(text="TIMER",fg=RED)
31+
canvas.itemconfig(countdown_text, text="00:00")
32+
check_mark.config(text=check)
33+
34+
35+
# ---------------------------- TIMER MECHANISM ------------------------------- #
36+
37+
def on_start():
38+
global reps
39+
40+
reps += 1
41+
42+
work_min = WORK_MIN * 60
43+
short_break_min = SHORT_BREAK_MIN * 60
44+
long_break_min = LONG_BREAK_MIN * 60
45+
46+
if reps == 9:
47+
label.config(text="WELL DONE",fg=RED)
48+
elif reps % 8 == 0:
49+
label.config(text="BREAK", fg=RED)
50+
countdown(long_break_min)
51+
elif reps % 2 == 0:
52+
label.config(text="BREAK", fg=PINK)
53+
countdown(short_break_min)
54+
else:
55+
56+
label.config(text="WORK", fg=GREEN)
57+
countdown(work_min)
58+
59+
60+
# ---------------------------- COUNTDOWN MECHANISM ------------------------------- #
61+
62+
def countdown(count):
63+
global check, timer
64+
min = math.floor(count / 60)
65+
sec = count % 60
66+
if sec == 0:
67+
sec = "00"
68+
if int(sec) < 10 and int(sec) > 0:
69+
sec = f"0{sec}"
70+
71+
canvas.itemconfig(countdown_text, text=f"{min}:{sec}")
72+
if count > 0:
73+
timer = window.after(1000, countdown, count-1)
74+
else:
75+
if reps % 2 != 0:
76+
check += "✔"
77+
check_mark.config(text=check)
78+
on_start()
79+
80+
# ---------------------------- UI SETUP ------------------------------- #
81+
window = Tk()
82+
window.title("Pomodoro")
83+
window.config(padx=100, pady=50, bg=YELLOW)
84+
85+
label = Label(text="Timer", font=(FONT_NAME, 30, "bold"), fg=GREEN, bg=YELLOW)
86+
label.config(pady=20)
87+
label.grid(row=0, column=1)
88+
89+
canvas = Canvas(width=200, height=224, bg=YELLOW, highlightthickness=0)
90+
tomato_img = PhotoImage(file="tomato.png")
91+
canvas.create_image(100, 112, image=tomato_img)
92+
countdown_text = canvas.create_text(100, 130, text="00:00", fill="black", font=(FONT_NAME, 22, "bold"))
93+
canvas.grid(row=1, column=1)
94+
95+
start_button = Button(text="Start", command=on_start, width=10)
96+
start_button.grid(row=2, column=0)
97+
98+
check_mark = Label(text=check, font=(FONT_NAME, 15, "bold"), fg=GREEN, bg=YELLOW)
99+
check_mark.grid(row=2, column=1)
100+
101+
reset_button = Button(text="Reset", command=on_reset, width=10)
102+
reset_button.grid(row=2, column=2)
103+
104+
window.mainloop()

‎Pomodoro-App/tomato.png

10.5 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.