

Now that the GUI is finished, it’s time to build the alarm function in Python Alarm Clock. Timeleft = Label(root,font=('arial', 20, 'bold')) These will also be formatted with Tkinter in the same manner as the hours.įinally, we’ll add a “set alarm” button with the following code: setbtn=Button(root,text="Set Timer!",command=setalarm,bg="#D4AC0D",įg="Black",font = ('arial', 19, 'bold')).grid(row=8,columnspan=4) We’ll then create two additional widgets, one for minutes and one for seconds. We’ll also set the default hour value to 0 until the user changes it. Text="Welcome At The ").grid(row=7,columnspan=6) Minbtn=Entry(root,textvariable=mins,width=5,įont = ('arial', 18, 'bold')).grid(row=4,column=2) Text="Set Your Alarm Clock!\n \n").grid(row=1,columnspan=4) # Creating and placing all the components of the window Because the clock operates on a 24-hour basis, the readings will range from 0 to 24. Then, we’ll create a widget that uses a StringVar to hold all of the hour values that users may select from. These labels, which will be centered in the window, will inform users about the software and how to interact with it. To begin, we’ll make two essential labels: “Alarm Clock” and “Set Time:”. Now that the GUI has been established, it is time to begin adding frames, labels, and buttons to the GUI. Step 3: Create the menus, buttons, and labels for the GUI In this case, we set the window size to 265×270 and the window resizability to false.


We’ll begin by launching Tkinter and creating a window for the Python Alarm Clock. As an example, let’s type:ĭownload The Audio file From here: # Importing all the necessary modulesįrom pygame import mixer Step 2: Creating Tkinter GUI # Setting the main screenĪfter all of the modules have been imported, it’s time to start Tkinter and design the program’s graphical user interface. You must first establish the Tkinter window and import the necessary libraries.

The datetime, time, and mixer modules from pygames will produce the alarm and sound effects, while the Tkinter library will be used for the visuals. Importing all of the necessary libraries and modules is the initial step in starting the project. Step 1: Importing the Necessary Libraries
