10 Twisted Timer

 

This chapter covers

  • Using sliders to select values
  • Time formats to set and calculate the remaining time
  • F string for joining separate text values together
  • Integer and modulo division
  • Loops (iteration) repeating sections of the code

The project in this chapter can be helpful or you can use it for twisted purposes. You will build an interactive countdown timer. You will have probably heard the term, countdown: it is the process of counting numbers in reverse order, to zero. It is commonly used before launching a rocket; there is a countdown from 10 to 0 before the ‘blast off’. Countdowns are also used before the start of a race! (Sometimes you may have a countdown before dinner, “It will be on the table in 3 minutes”, “It will be ion the table in 2 minutes”, it will be on the table in 1 minute”!

Your countdown timer can be used for good intentions; for example, if you are studying, you can set the timer for 30 minutes. Do you play a musical instrument? The timer can be used to time a 20-minute practice session. When you take a break and you want to know how much time remains, use the countdown timer. For a more twisted intention, you can use the app to time a prank that you are playing on someone!

WHAT YOU WILL BUILD

Creating the project

Getting started

How the countdown timer works

Importing the modules

Declaring the variables

Creating the Three Slider Functions

Creating the other countdown functions

Creating a function to calculate the total time

Creating the function to begin the countdown

Creating the countdown() function

Creating the reset_countdown() function

Building the main app

Running and testing your GUI program

Other things try

Summary