diff --git a/birthday.html b/birthday.html new file mode 100644 index 0000000000000000000000000000000000000000..427834ccb9da5db552a64383c5f3947c4c67cc27 --- /dev/null +++ b/birthday.html @@ -0,0 +1,66 @@ +import tkinter as tk +import random +import time + +# 初始化主窗口 +root = tk.Tk() +root.title('生日快乐飘字') +root.geometry('600x800') +root.configure(bg='pink') +root.attributes('-topmost', True) # 窗口置顶 + +# 定义生日祝福文本列表 +tips = [ + "生日快乐呀", "愿你每天都笑靥如花", "心想事成", "岁岁常欢愉", + "年年皆胜意", "永远青春可爱", "所求皆所愿,所行皆坦途", + "生日快乐,不止今天", "愿你被世界温柔以待", "天天都有小惊喜", + "快乐不止生日", "愿你成长不期而遇,生日如期而至", "愿你成为自己喜欢的样子" +] + +# 定义颜色列表 +colors = ["#ffb6c1", "#fff0f5", "#ffc0cb", "#ffd1dc", "#fce4ec"] + +# 显示生日祝福弹窗 +def show_birthday_popup(): + popup = tk.Toplevel(root) + popup.title("生日祝福") + popup.geometry("300x150") + popup.resizable(False, False) + popup.configure(bg='gold') + + tk.Label(popup, text="生日祝福", font=("Arial", 16, "bold"), bg='gold').pack(pady=10) + tk.Label(popup, text="您有一份生日祝福,确定要打开吗?", bg='gold').pack() + + def open_gift(): + popup.destroy() + root.after(500, create_tips) # 延迟创建飘字 + + tk.Button(popup, text="确定", command=open_gift, bg='white').pack(pady=10) + +# 创建飘字 +def create_tips(): + for tip in tips: + # 随机位置、颜色、字体大小 + x = random.randint(50, 550) + y = random.randint(50, 750) + color = random.choice(colors) + font_size = random.randint(12, 16) + + label = tk.Label(root, text=tip, font=("Arial", font_size), bg='pink', fg=color) + label.place(x=x, y=y) + + # 让标签慢慢向上移动并消失 + def move_label(lbl, pos_y): + if pos_y > -50: + lbl.place(y=pos_y - 1) + root.after(50, lambda: move_label(lbl, pos_y - 1)) + else: + lbl.destroy() + + move_label(label, y) + time.sleep(0.5) # 每个提示间隔显示 + +# 先显示弹窗 +show_birthday_popup() + +root.mainloop() \ No newline at end of file