Magic With Tkinter ! Python is Amazing #viral #shorts #programming #youtubeshorts
Full Code - import tkinter as tk
import time
import random
#this script i have created for a digital clock
#using tkinter and it will change colour as well
#below is the whole code
#i will put the code in description as well if you need
#lets see the amazing tkinter output
class DigitalClock:
def __init__(self, root):
self.root = root
self.root.title("Digital Clock with Color Change")
self.root.geometry("400x200")
self.label = tk.Label(root, font=("Helvetica", 48), bg="black", fg="white")
self.label.pack(expand=True)
self.update_clock()
self.change_color()
def update_clock(self):
current_time = time.strftime("%H:%M:%S")
self.label.config(text=current_time)
self.root.after(1000, self.update_clock)
def change_color(self):
colors = ["red", "green", "blue", "yellow", "purple", "orange"]
bg_color = random.choice(colors)
self.label.config(bg=bg_color)
self.root.after(5000, self.change_color) # Change color every 5 seconds
if _name_ == "__main__":
root = tk.Tk()
clock = DigitalClock(root)
root.mainloop()