Make a Python Digital Clock (In Visual Studio Code)

Publicado em: 10 Junho 2024
no canal de: Shurjoe Chakraborty "CG Robot"
78
3

This is the code :-

import tkinter as tk
from time import strftime, localtime

class DigitalClock:
def __init__(self, root):
self.root = root
self.root.title("Digital Clock")
self.root.configure(background="black")

self.time_label = tk.Label(self.root, font=("Futura", 24, "bold"), fg="white", bg="black", bd=3, relief=tk.SOLID)
self.time_label.pack(pady=20)

self.date_label_frame = tk.LabelFrame(self.root, text="", font=("Futura", 10), fg="white", bg="firebrick", bd=3, relief=tk.SOLID)
self.date_label_frame.pack(pady=10, padx=10)

self.date_label = tk.Label(self.date_label_frame, font=("Futura", 10), fg="white", bg="firebrick")
self.date_label.pack(padx=10, pady=5)

self.update_clock()

def update_clock(self):
current_time = strftime("%I:%M:%S %p", localtime())
current_date = strftime("%A, %B %d, %Y", localtime())

self.time_label.config(text=current_time)
self.date_label.config(text=current_date)

self.root.after(1000, self.update_clock)

if _name_ == "__main__":
root = tk.Tk()
root.geometry("200x150")
clock = DigitalClock(root)
root.mainloop()

Please Subscribe and Like my video. And wait for my next video
Hope you like my video.


Nesta página do site você pode assistir ao vídeo on-line Make a Python Digital Clock (In Visual Studio Code) duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Shurjoe Chakraborty "CG Robot" 10 Junho 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 78 vezes e gostou 3 espectadores. Boa visualização!