import tkinter as tk
import random
import threading
import time
def show_warm_tip():
try:
window = tk.Tk()
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
window_width = 250
window_height = 60
x = random.randrange(0, screen_width - window_width)
y = random.randrange(0, screen_height - window_height)
window.title('想你')
window.geometry(f"{window_width}x{window_height}+{x}+{y}")
tips = [
'多喝水哦~', '保持微笑呀', '每天都要元气满满', '记得吃水果',
'保持好心情', '好好爱自己', '我想你了', '梦想成真',
'期待下一次见面', '金榜题名', '顺顺利利', '早点休息',
'愿所有烦恼都消失', '别熬夜', '今天过得开心嘛', '天冷了,多穿衣服'
]
tip = random.choice(tips)
bg_colors = [
'lightpink', 'skyblue', 'lightgreen', 'lavender', 'lightyellow',
'plum', 'coral', 'bisque', 'aquamarine', 'mistyrose',
'honeydew', 'lavenderblush', 'oldlace'
]
bg = random.choice(bg_colors)
tk.Label(window, text=tip, bg=bg, font=('微软雅黑', 16), width=30, height=3).pack()
window.attributes('-topmost', True)
window.after(10000, window.destroy)
window.mainloop()
except Exception as e:
print(f"Error creating window: {e}")
threads = []
for i in range(50):
t = threading.Thread(target=show_warm_tip)
threads.append(t)
time.sleep(0.5)
t.start()