Mini strategy Tkinter GUI Alarm timekeeper –
Python’s standard library is truly expansive, offering a wide range of installations. The library contains constructed-in modules ( written in C) that supply access to system functionality similar as line I/ O that would else be inconvenient to Python programmers, as well as modules written in Python that deliver standardized results for numerous problems that do in everyday programming.
About the Python Project:
The ideal of our system is to apply an alarm timekeeper using Python. Python consists of some veritably innovative libraries similar as datetime and tkinter which help us to put up the design using the current date and time as well as to give a user interface to set the alarm according to the demand in 24-hour format.
The prerequisites are beginning notions of Python and Tkinter.
⮚ Tkinter Module:
Tkinter is a Python binding to the Tk GUI toolkit.Both Tk and tkinter are available on ultimate Unix platforms, including macOS, as well as on Windows systems.
Important Tk notions:
A Tkinter user interface is made up of individual widgets. Each widget is represented as a Python object, expressed from classes likettk,Frame,ttk.Label and ttk.Button.
Tkinter reacts to user input, changes from your program, and indeed refreshes the display only when actively running an eventloop.However, your user interface will not update, If your program is not running the event loop.
⮚ DateTime Library:
Datetime and time modules in python help us to work with the dates and time of the current day when the user is operating python and to manipulate it too.
⮚ Mixer Module for audio files:
In order to play music/audio files in pygame,pygame.mixer is used(pygame module for loading and playing sounds).This module
contains classes for loading sound objects and controlling playback.Install library using following command:
Source code for project:
Step 1 : Importing all libraries :
Step 2 : Creating GUI window by initializing Tk( ) function. and actively running an evenloop by using mainloop() function.
Step 3: After initializing window ,set up a following things for good looking window refer the following source code with comments:
Step 4: Written user defined function alarm() and stopalarm().
alarm: This is the most important method because it performs the following tasks:
- It stores the hour and sec from taking value from user.
- Display current time in time_now in specified format date,time and day.
- It also checks if setting time matches the current time. As soon as time matches it plays the alarm song using pygame and mixer.
stopalarm: This is the most important method because it performs the following tasks:
- It asks user the to stop,resume and pause the alarm. b. If user press ‘p’ then pause the song
- If user press ‘r’ then unpause the song
- If user press ‘e’ then stop the song.
With this mini strategy in Python using GUI library Tkinter, we have successfully made the Alarm Timekeeper. We learned how to source the current time from the computer and to use it for manipulation using the DateTime library. Written two functions ,one for set the alarm time which play the ring tone song using mixer library and second function which is used to stop the alarm.
We can also implemented this strategy in major project by adding multiple alarm options and extend the alarm next 10 min.etc.We can implement and deploy complete our application of alarm clock TimeKeeper.
Call the Trainer and Book your free demo Class Call now!!!
| SevenMentor Pvt Ltd.
© Copyright 2021 | Sevenmentor Pvt Ltd.