Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Alarm Tool

Here are examples of alarm tools you can use for inspiration:

Here are resources that you can use to build your alarm tool:

  • sqlite3: A self-contained, serverless, transactional SQL database engine
  • Pygame: A set of Python modules designed for writing video games
  • PyMedia: Python module to encode/decode audio compressed streams
  • simpleaudio: Cross-platform, dependency-free audio playback capability for Python3

00:00 Alarm tool. Time and tide wait for no man, as they say, but with a lot of things going on in our lives, it’s difficult not to lose track of time. To be able to keep track of it, a reminder is needed, and this is where the alarm tool can come in, giving an audio or visual signal that a time has been reached or that a timer has expired. With this tool, users will be able to set alarms to remind them of certain times of day, working from their computer’s operating system and replacing a physical alarm clock.

00:29 Let’s take a look at a couple of implementations of this kind of project. Firstly, with the timer on the Mac. Here, you can see the Timer application running on the Mac.

00:39 I’m going to zoom in so you can see a little clearer. The alarm mode is what we’re interested in, and you can set the time easily using these controls or with text entry.

00:51 It’s possible to turn the alarm ON and OFF

00:54 and also to choose an Action when the alarm goes off. Clearly, in the first part of your project, you’d probably want to stick to something simple, such as playing sound or displaying a message, but it’s possible here to see a range of different actions, all of which could make the alarm much more useful.

01:13 Here, you can see Free Alarm Clock in action with the default repeating alarm set up already. Now, let’s add a new alarm. Here, you can see the alarm adding interface.

01:24 You can type a time in or click this button to use the rather unusual way of picking a time using these blocks. Clearly, this would be easy to implement, but it’s a little unusual for the user.

01:37 It’s possible to select which audio file will be played…

01:43 and also to audition it, as you can hear.

01:47 Other options are present here as well, which you may need to implement as part of your extra challenges.

01:54 Let’s take a look at some of the technical challenges you’ll need to overcome to implement your alarm tool. As with many of the projects we’ve seen: storage of information.

02:02 The alarm tool will need to store data about the alarm times, the types, dates, and other information. Storing this using sqlite3 may well be the most pragmatic approach, as well as giving the option of using historical alarm settings to allow future settings to be predicted. Create, edit, and deleting alarms.

02:21 Implementing a simple interface for setting times is important, and an efficient time-picking interface can mean an application will be a joy to use. The interface of your program is its hand shake, so you have to make sure that it has a good one. Audio playback.

02:37 If you’ve already programmed the audio player, then this should be a breeze. You may choose to use a simple tone or allow playback of an audio file for an alarm.

02:46 This opens up all sorts of possibilities, or even a hybrid audio player and alarm clock application.

02:53 Now, let’s take a look at some extra challenges you can take on when you’ve got the basic alarm tool up and running. Firstly, repeating alarms. Being able to set repeating alarms should be a straightforward task, but perhaps you could analyze previous alarms to see which ones will need to be repeated, and when. Snooze. A snooze function is included in most physical alarm clocks, so implementing this should be attempted—possibly setting limits of number and the length of snoozes. Notifications.

03:23 As you saw from the timer application on the Mac, it’s a good idea to be able to choose different events to happen once the alarm goes off. It’s possible the user will be away from their computer when their alarm goes off, so integrating a notifications API to allow notifications on other devices is a worthwhile extra to look into.

Become a Member to join the conversation.