User Tools

Site Tools


otherpy

This is an old revision of the document!


Worldclock

import tkinter as tk
from datetime import datetime
from zoneinfo import ZoneInfo
 
def update_clocks():
    berlin_time = datetime.now(ZoneInfo("Europe/Berlin")).strftime("%H:%M:%S")
    melbourne_time = datetime.now(ZoneInfo("Australia/Melbourne")).strftime("%H:%M:%S")
    victoria_time = datetime.now(ZoneInfo("America/Vancouver")).strftime("%H:%M:%S")
    charleston_time = datetime.now(ZoneInfo("America/New_York")).strftime("%H:%M:%S")
 
    berlin_label.config(text=f"Berlin 🇩🇪: {berlin_time}")
    melbourne_label.config(text=f"Melbourne 🇦🇺: {melbourne_time}")
    victoria_label.config(text=f"Victoria 🇨🇦: {victoria_time}")
    charleston_label.config(text=f"Charleston 🇺🇸: {charleston_time}")
 
    root.after(1000, update_clocks)
 
root = tk.Tk()
root.title("🌍 Weltzeit-Uhren")
 
berlin_label = tk.Label(root, font=("Helvetica", 20), fg="black")
melbourne_label = tk.Label(root, font=("Helvetica", 20), fg="blue")
victoria_label = tk.Label(root, font=("Helvetica", 20), fg="green")
charleston_label = tk.Label(root, font=("Helvetica", 20), fg="purple")
 
berlin_label.pack(pady=10)
melbourne_label.pack(pady=10)
victoria_label.pack(pady=10)
charleston_label.pack(pady=10)
 
update_clocks()
root.mainloop()
otherpy.1760805450.txt.gz · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki