Time For a Break

Pooja Juyal is manager at Samtel Avionics Ltd


This is a computer based program to remind you to take regular breaks while working on your desk for good health. Some of us spend at least sixty per cent (if not more) of our day sitting on a chair working on a computer or for some other work. This physical inactivity for such long durations causes diseases like varicose veins, weak bones, back problems, weak digestion and can even increase the risk of cancer. Doctors around the world suggest good posture while sitting and taking regular breaks from your work. You can walk around and stretch a little bit for a healthy life.

Here is what the software does. Once installed, it reminds you to take a break after a predetermined time through an audio announcement. It also randomly selects a video from a list (already fed in the program) and plays it to further motivate you to leave the desk and move around.

Software program

The software is written in Python programming language. All steps, from installation, program creation to running the program, are included in this article to help you get started with Python programing language. Various modules including webbrowser, random, time and pyttsx are used in the program that could be useful for other Python based projects including embedded systems. The software performs well on Window7/Windows10 systems.

Download and install Python. Python is available in two versions: Python 2 and Python 3. We have used Python 2.7.11 for our program. Download and install this version of Python before writing the program. You can download it from https://www.python.org/downloads/
Open the link; you will see the page as shown in Fig. 1. Click on Download Python 2.7.11 (marked by red arrow in the figure).

Python Download Page
Fig. 1: Download page

Once downloaded, install the software by following the steps given below:
1. Double-click on the downloaded file.

2. Select Install for all users option and click Next (Fig. 2).

Fig. 2: Selecting Install for all users option

3. Select the location to install Python. Click Next.

4. Keep the default selection (Fig. 3) and click Next.

Fig. 3: Choosing the default destination path

5. You will be prompted for permission to install the software; select Yes. Page shown in Fig. 4 will appear to indicate the status of installation. Once finished, Next tab will be activated.

Fig. 4: Screen showing the status of installation

6. Click Finish to complete the software installation.

Fig. 5: Finish installation screen

Add Python to path environment variable

Python can be directly run through Command Prompt on Windows. But this needs addition of Python directories to the path under System Variables as explained below. If you run python.exe command immediately after installation without adding the path, you may encounter the error shown in Fig. 6.

Fig. 6: Error message

Follow the steps below to add Python to Environment Variables path:
1. Right-click on My Computer, then Properties and then Advanced System Settings (Fig. 7).

Fig. 7: Advanced System Settings

Click on Environment Variables and search for the Path variable. Select Path variable and click on Edit (Fig. 8).

Fig. 8: Path under System Variables

2. In case of Windows 7, add the following at the end of the variable value:

3. In case of Windows 8 or above, window shown in Fig. 9 will appear. Click on New and add:

Fig. 9: Path in Windows 8

4. Select OK, and it is done.

5. Open Command Prompt and type python (Fig. 10). This screen confirms proper installation of Python.

Fig. 10: Command Prompt

Note down the Python version and architecture. This will be required later in the article while downloading pywin.

6. Now, you can directly run Python commands from Command Prompt.

Python IDE

Python IDE comes with Python installation and is used to write, test and debug Python programs.

You can run it directly from the installed applications by clicking on its logo. Or, you can write IDLE in the search tab on Windows start button, click on IDLE (Python GUI) option. You will get Python shell screen as shown in Fig. 11.

Python IDLE (GUI) screen
Fig. 11: Python IDLE (GUI) screen

Python is an interpreted language, so you can immediately start writing the commands, followed by pressing Enter on the keyboard. Commands get executed when you do this. Test by typing 2+2 and then press Enter. You should get four as the answer in the next line.

Create new program

Run Python IDLE→File→New File.

Start writing the program in IDLE. The complete program has been provided in takabreak.py file (Fig. 12), and it is recommended to copy the code from this file, or use the file as it is, because Python is an indentation-sensitive language.

takabreak.py on Python GUI window
Fig. 12: takabreak.py on Python GUI window

Importing modules

Let us start with importing different modules that would be required in the program.
import webbrowser
# importing webbrowser module to run videos from youtube
import random
# importing random module to select randomly from a list
import time
# importing time module for delays
import pyttsx
# text to speech module

The first three modules are packaged with Python standard library, so you do not have to install these. You can check all different modules in Python standard library from https://docs.python.org/2/library/


Please enter your comment!
Please enter your name here