Digital clock using PyQt5 in PythonIn this post, we'll see at how to make a digital clock using PyQt5, which essentially displays the time in 24-hour format. We will be focussing on making a GUI that will show the current time in HH:MM:SS format by opening a window. The following must be done in order to make a digital clock :
Walking through the code :Firstly, we will import all the libraries required by our program, that include QtWidgets, QtGui, QtCore and sys. Next, we will create a new class to initialize our GUI window and start setting the geometry, adding fonts, creating labels, setting alignment and displaying widgets. Next, we will create the layout of our window. Then, we will create a timer clock timer, add a functionality to it for getting updated after every second and call the function linked to it. Next, we will create a function that contains the present time to be displayed, the time label to be updated and the text display field. Finally, we will create the application and the instance of the window. Then, the instance created will be displayed and the program will be called to execute and start the application. Complete code :Output: The output of the above mentioned code is attached below in the for of screenshot, Next TopicCountdown Timer using PyQt5 in Python |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India