显示一个透明弹窗,上面有倒计时
只是一个简单的实验程序,没有做到开机自启和数据记录
import tkinter as tk
import datetime
#####################################
# 想要拥有流浪地球同款的倒计时吗?
# 程序封装: @通用中文名
#####################################
#导包
class app(object):
def Body(self, message):
root.geometry('600x400+840+560')
L1 = tk.Canvas(root)
#定义窗口大小
L1.create_line(20, 130, 20, 28, width=4, fill="red")
L1.place(x=236, y=30)
#显示红色竖杠,并部署
Lbl1 = tk.Label(root, text="离"+message+" ", fg="white", padx=10,width=60,
font=("微软雅黑", 25), anchor='e')
Lbl1.pack()
#显示日程内容部分,并部署
Lbl2 = tk.Label(root, text="还 剩", fg="white",
font=("微软雅黑", 25))
Lbl2.pack()
#同上...
def Days(self, dada):
now = datetime.datetime.now()
#获取现在时间
ad = datetime.datetime.strptime(dada, "%Y-%m-%d")
num = (ad-now).days
#计算天数差
Lbl3 = tk.Label(root, text=num, fg="red",
font=("微软雅黑",78))
Lbl3.place(x=340,y=-25)
Lbl4 = tk.Label(root, text="天", fg="white",
font=("微软雅黑",25)
)
Lbl4.place(x=480,y=52)
def introduce(self, in):
Lbl5 = tk.Label(root, text=in, fg="white", wraplength=260,justify='left',
font=("微软雅黑",13))
Lbl5.place(x=261,y=100)
def hideen(self):
root.attributes("-transparentcolor","#F0F0F0")
root.attributes("-toolwindow",True)
root.overrideredirect(True)
root.mainloop()
def run(self):
mes = input("倒计时日程:")
ind = input("请输入简介:")
da = input("输入目标时间,格式xxxx-xx-xx:")
self.Body(mes)
self.Days(da)
self.introduce(ind)
self.hideen()
root = tk.Tk()
app().run()