- import tkinter as tk
- import time as t
- win=tk.Tk()
- win.attributes("-alpha",0.7)
- win.attributes("-toolwindow",1)
- win.attributes("-topmost",1)
- win.title("小時鐘")
- win.resizable(0,0)
- lbtext=tk.StringVar()
- def showtime():
- lbtext.set(t.strftime("%Y %m %d %a %H:%M:%S"))
- win.after(1000,showtime)
- lb=tk.Label(win,bg="black",fg="white",textvariable=lbtext,font=("微軟正黑體",16),width=25,height=3,anchor="center").pack()
- showtime()
- win.mainloop()
複製代碼 |