This content got low rating by people.

Digital Clock with Python : Learn to Code


DigitalClock.py

import tkinter as tk
from tkinter import Label
import time

# Create the main window
root = tk.Tk()
root.title("Digital Clock")

# Define the clock function
def clock():
    # Get the current time
    current_time = time.strftime("%H:%M:%S %p")
    # Update the label with the current time
    clock_label.config(text=current_time)
    # Call the clock function after 1000ms (1 second)
    clock_label.after(1000, clock)

# Create a label to display the time
clock_label = Label(root, font=('calibri', 40, 'bold'), background='purple', foreground='white')
clock_label.pack(anchor='center')

# Call the clock function to update the time
clock()

# Start the main loop
root.mainloop()
H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center