From 7a80291e549267d0373784a4e79ee7610cb054ed Mon Sep 17 00:00:00 2001 From: Cx330 <1487537121@qq.com> Date: Fri, 14 Nov 2025 12:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=98=E5=AD=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..ce870af --- /dev/null +++ b/main.py @@ -0,0 +1,53 @@ +import tkinter as tk +import random +import time + +messages = [ + '我想你了', '保持好心情', '梦想成真', + '早点休息', '今天过得开心嘛', '好想见到你', + '金榜题名', '多喝水哦~', '好好爱自己', + '记得吃水果', '顺顺利利', '期待下一次见面', + '午饭要吃热乎的', '你超棒的!', '保持微笑呀', + '别熬夜', '你已经做得很好啦', '天冷,多穿衣服', + '愿今晚有个好梦', '我爱你,老妈' +] + +def get_random_color(): + colors = ['pink', 'lightblue', 'lightgreen', 'lightyellow', + 'lavender', 'mistyrose', 'paleturquoise', 'peachpuff' + ] + return random.choice(colors) + +def create_float_windows(root): + window = tk.Toplevel(root) + + width = root.winfo_screenwidth() + height = root.winfo_screenheight() + + x = random.randrange(0, width - 200) + y = random.randrange(0, height - 100) + window.geometry(f"+{x}+{y}") + + message = random.choice(messages) + color = get_random_color() + + tk.Label(window, + text=message, + bg=color, + font=('楷体',18), + width=15, + height=2).pack() + +def create_windows_periodicoally(root, count=100, delay=50): + if count > 0: + create_float_windows(root) + + root.after(delay, create_windows_periodicoally, root, count - 1, delay) + +if __name__ == "__main__": + root = tk.Tk() + root.withdraw() + + create_windows_periodicoally(root, 200, 70) + + root.mainloop() \ No newline at end of file