The Pomodoro technique is a popular way to track and improve your productivity. Developed by Francecso Cirillo, an Italian software engineer who needed a way to stay focused on his studies, the technique is both simple and effective. A Pomodoro is a set time for staying on tasks, followed by a quick break. Traditionally, the ratio works like this: 25 minutes on task, followed by a 5 minute break. You can technically work in Pomodoros with something as simple as a kitchen timer or stopwatch. Just set the timer for 25 minutes, get on task, and once 25 minutes has passed, take your break, then repeat. Once you’ve done 5 Pomos in a row, take a longer break — somewhere between 15 and 30 minutes. But most people see the benefit of finding a Pomodoro app that lets them use their phone or computer to increase productivity.
Installation:
You need to create a py file and download the image named tomato.png, you need to put them in the same folder and run the python file.
Code:
from tkinter import *
import math
# ---------------------------- CONSTANTS ------------------------------- #
PINK = "#e2979c"
RED = "#e7305b"
GREEN = "#9bdeac"
YELLOW = "#f7f5dd"
FONT_NAME = "Courier"
WORK_MIN = 25
SHORT_BREAK_MIN = 5
LONG_BREAK_MIN = 20
reps = 0
timer = None
# ---------------------------- TIMER RESET ------------------------------- #
def reset_timer():
window.after_cancel(timer)
# Time Text Reset.
canvas.itemconfig(timer_text, text="00:00")
# Title Label Reset.
timer_label.config(text="Timer")
# Reset checkmarks.
checkmark_button.config(text="")
# Reset reps.
global reps
reps = 0
# ---------------------------- TIMER MECHANISM ------------------------------- #
def start_timer():
global reps
reps += 1
work_sec = WORK_MIN * 60
short_break_sec = SHORT_BREAK_MIN * 60
long_break_sec = LONG_BREAK_MIN * 60
if reps % 8 == 0:
countdown(long_break_sec)
timer_label.config(text="Break", fg=RED)
elif reps % 2 == 0:
countdown(short_break_sec)
timer_label.config(text="Break", fg=PINK)
else:
countdown(work_sec)
timer_label.config(text="Work", fg=GREEN)
# ---------------------------- COUNTDOWN MECHANISM ------------------------------- #
def countdown(count):
count_minute = math.floor(count / 60)
count_seconds = count % 60
if count_seconds < 10:
count_seconds = f"0{count_seconds}"
canvas.itemconfig(timer_text, text=f"{count_minute}:{count_seconds}")
if count > 0:
global timer
timer = window.after(1000, countdown, count - 1)
else:
start_timer()
mark = ""
work_sessions = math.floor(reps / 2)
for _ in range(work_sessions):
mark += "✅"
checkmark_button.config(text=mark)
# ---------------------------- UI SETUP ------------------------------- #
window = Tk()
window.title("Pomodoro")
window.config(padx=100, pady=50, bg=YELLOW)
# Add Timer Label
timer_label = Label(text="Timer", font=(FONT_NAME, 40, "bold"), fg=GREEN, bg=YELLOW)
timer_label.grid(row=0, column=1)
# Add Image
canvas = Canvas(width=200, height=224, bg=YELLOW, highlightthickness=0)
tomato_image = PhotoImage(file="tomato.png")
canvas.create_image(100, 112, image=tomato_image)
# Create Text
timer_text = canvas.create_text(100, 139, text="00:00", fill="white", font=(FONT_NAME, 35, "bold"))
canvas.grid(row=1, column=1)
# Start Button
start_button = Button(text="Start", highlightthickness=0, command=start_timer)
start_button.grid(row=2, column=0)
# Reset Button
reset_button = Button(text="Reset", highlightthickness=0, command=reset_timer)
reset_button.grid(row=2, column=2)
# Checkmark Button
checkmark_button = Label(fg=GREEN, bg=YELLOW)
checkmark_button.grid(row=3, column=1)
window.mainloop()
Download files: