May-03-2024, 03:37 AM
Hi Forum,
I'm using tis code to create a World clock for 4 Countries.
I've copied the code and understand the logic, but i must have made an error as it doesn't show a frame with 4 different Countries timezones.
Can anyone see why this isn't working?
Thanks.
I'm using tis code to create a World clock for 4 Countries.
I've copied the code and understand the logic, but i must have made an error as it doesn't show a frame with 4 different Countries timezones.
Can anyone see why this isn't working?
Thanks.
# https://www.google.com/search?sca_esv=08156674d0b13f07&sca_upv=1&rlz=1C1VDKB_enAU1081AU1105&cs=0&sxsrf=ADLYWIKKYe2lYbhYyIu46OSDBaPbekhPFg:1714698269306&q=World+clock+in+Python&sa=X&ved=2ahUKEwi0uO7ppPCFAxVcd2wGHYRwCFMQpboHegQIARAA&biw=1920&bih=911&dpr=1#fpstate=ive&vld=cid:10837df9,vid:zFCp7iczAPk,st:0 from datetime import datetime import pytz from tkinter import * import time root = Tk() root.geometry("500x250") def times(): home=pytz.timezone('Australia/Victoria') local_time=datetime.now(home) current_time=local_time.strftime("%H:%M:%S") clock.config(text=current_time) name.config(text="Australia") clock.after(200,times) home = pytz.timezone('Asia/Kolkata') local_time = datetime.now(home) current_time = local_time.strftime("%H:%M:%S") clock1.config(text = current_time) name1.config(text = "India") home = pytz.timezone('America/New_York') local_time = datetime.now(home) current_time = local_time.strftime("%H:%M:%S") clock2.config(text = current_time) name2.config(text = "U.S.A") home = pytz.timezone('UTC') local_time = datetime.now(home) current_time = local_time.strftime("%H:%M:%S") clock3.config(text = current_time) name3.config(text = "UTC") clock.after(200,times) # Australian Time AEST name = Label(root,font = ("times",20,"bold")) name.place(x = 30, y = 5) clock = Label(root,font = ("times",15,"bold")) clock.place(x = 10, y = 40) nota = Label(root, text = "Hours Minutes Seconds",font = "times 10 bold") nota.place(x = 10, y = 80) # Indian Time IST name1 = Label(root, font = ("times",20,"bold")) name1.place(x = 330, y = 5) clock1 = Label(root, font = ("times",25,"bold")) clock1.place(x = 310, y = 40) nota1 = Label(root, text = "Hours Minutes Seconds",font = "times 10 bold") nota1.place(x = 310, y = 80) # American Time name2 = Label(root,font = ("times",20,"bold")) name2.place(x = 30, y = 105) clock2 = Label(root, font = ("times",25,"bold")) clock2.place(x = 10, y = 140) nota2 = Label(root, text = "Hours Minutes Seconds",font = "times 10 bold") nota2.place(x = 10, y = 180) # UTC name3 = Label(root,font = ("times",20,"bold")) name3.place(x = 330, y = 105) clock3 = Label(root, font = ("times",25,"bold")) clock3.place(x = 310, y = 140) nota3 = Label(root, text = "Hours Minutes Seconds",font = "times 10 bold") nota3.place(x = 310, y = 180) root.mainloop()