Jacy’s Pomodoro Technique

Breaking into the industry: My Journey to becoming a Software Engineer #7 — Pomodoro Technique

M E

--

In this episode of my journey to becoming a Software Engineer, I created a Pomodoro Technique using Tkinter. This project is a great time management tool that improves productivity and most importantly, increases retention.

Let me tell you a little bit about The Pomodoro Technique. It is basically a tool that helps someone focus on a particular task. It is a timer that break down four 25-minute time interval with a 5-minute break in between.

The Pomodoro Technique

Setting up the UI

When I was creating the UI, I used the Tkinter Canvas. A Canvas can be basically used to draw or add images on the Tkinter’s window. I used Canvas so I can easily add widgets such as an image. I added the “tomato” image using Canvas, so I can display the “timer” text on top of the image. To load the image, it must be saved in a variable (in this case tomato_photo) and use the PhotoImage function with the correct file path/directory. Then, load the image on canvas with the specific coordinates (in this case x=100 and y=112 because the size of the window is 200x224) to be centered.

Snippet of the UI.
countdown() function.

Countdown Function

Next on the agenda is to create a countdown() function that takes an input (count) in a form of integer to count down by. To have a better “time” visualization format, it will basically convert the input into minutes (count_min) using the math module and also convert the input into seconds (count_sec). These variables will be used to display as texts on the canvas (e.g. 25:00). Furthermore, if count is greater than zero (e.g. if the count parameter is 1500 (25 mins * 60 secs) then using Tkinter’s window it will have 1000 seconds delay, call the countdown function and decrement the count by 1); however, if count is equals/less than 0, then the start_timer() function will be called.

Timer Function

I created a function called start_timer() and it will be called when the user clicks on the “start” button and it is responsible for calling the coundown(count) function. The variable “WORK_MIN” is basically the 25 minute Pomodoro Technique work interval, “SHORT_BREAK_MIN” is the 5 minute break in between work intervals (25 minutes) and lastly the “LONG_BREAK_MIN” is the 20 minute break after completing 4 work intervals.

I have disabled double clicking on the “start_button” so when the user clicks that “start_button,” their only choice is click the “reset_button” to start over.

reset_timer() function.

The “WORK_MIN,” “SHORT_BREAK_MIN” and “LONG_BREAK_MIN” variables are converted into seconds and used as the “count” parameter in the countdown(count) function. Since we have to run four 25 minute work interval, the “rep” variable is incremented by 1 and the first 25 minute interval (work_sec) is basically the first rep. The second rep would be the 5 minute break (short_break_sec). Therefore, if rep is 1, 3, 5, 7, then coundown(work_sec) will be called. On the other hand, if the rep 2, 4, 6, then countdown(short_break_sec) will be called. Lastly, if the rep is 8, then that means the four 25 minute intervals have been completed and it is time for the 20 minute long break, and countdown(long_break_sec) will be called.

Additionally, once the work session (one 25 minute interval) is finished, then the timer goes to zero and a “green checkmark” will be displayed on the screen. When there are four green checkmarks, then that means all four 25 minute work intervals have been completed and it is time for the long 20 minute break.

Please check out the complete code on my GitHub account. :)

--

--