How to Create Clock Using Python - learnit

Home Top Ad

Post Top Ad

Friday, April 16, 2021

How to Create Clock Using Python

How to Create Clock Using Python

How to Create Clock Using Python

Python

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. Guido van Rossum during 1985- 1990, created it. Like Perl, Python source code is also available under the GNU General Public License (GPL). This tutorial gives enough understanding on Python programming language.


Why to Learn Python

Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages.


Python is necessary for students and working professionals to become a great Software Engineer especially when they are working in Web Development Domain. I will list down some of the key advantages of learning Python

    Python is Interpreted − the interpreter processes Python at runtime. You do not need to compile your program before executing it. This is similar to PERL and PHP.

    Python is Interactive − you can actually sit at a Python prompt and interact with the interpreter directly to write your programs.

    Python is Object-Oriented − Python supports Object-Oriented style or technique of programming that encapsulates code within objects.

    Python is a Beginner's Language − Python is a great language for the beginner-level programmers and supports the development of a wide range of applications from simple text processing to WWW browsers to Application or Project.


Create Clock Using Python and Example

Create Clock Using Python As we know, Tkinter is used to create a variety of GUI (Graphical User Interface) applications. In this article, we will learn how to create a Digital clock using Tkinter.

Prerequisites:
-Python functions
-Tkinter basics (Label Widget)
-Time module

Example


from tkinter import *
import time
root=Tk()
root.title('reanits.com')
root.iconbitmap('1.png')
root.geometry('300x400')
def clock():
hour = time.strftime("%H")
minute = time.strftime("%M")
second = time.strftime("%S")
timek = time.strftime("%r")
timezone = time.strftime("%z")
mylabel.config(text=hour + ":" + minute + ":" + second + ":" + timek)
mylabel.after(1000,clock)
mylabel1.config(text=timezone)
mylabel= Label(root, text="", font=("Khmer OS", 40), fg="green", bg="black")
mylabel.pack(pady=20)
mylabel1= Label(root, text="",font=("Khmer OS",40),fg="green")
mylabel1.pack(pady=20)
clock()
root.mainloop()


Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad