import tkinter as tk
from time import strftime

# 创建主窗口
root = tk.Tk()
root.title("Python 时钟")
root.geometry("300x150")
root.resizable(False, False)

# 设置字体和颜色（可选）
label = tk.Label(
    root,
    font=('Helvetica', 40, 'bold'),
    background='black',
    foreground='cyan'
)
label.pack(anchor='center')

# 更新时间的函数
def update_time():
    current_time = strftime('%H:%M:%S')
    label.config(text=current_time)
    label.after(1000, update_time)  # 每1000毫秒（1秒）调用一次自己

# 启动时钟
update_time()

# 进入主事件循环
root.mainloop()