视频:
import tkinter as tk
import random
WINDOW_W, WINDOW_H = 300, 100 # 单个窗口尺寸
COUNT = 400 # 弹窗数量
SPAWN_INTERVAL_MS = 30 # 平均弹出间隔(越小越快)
AUTO_CLOSE_MS = 9000 # 自动关闭时间(毫秒)
tips = [
"多喝水呀~", "保持微笑呀~", "今天要开心哦~",
"别熬夜啦~", "休息一下吧~", "好好爱自己~",
"我想你了~", "加油呀~", "一切都会好起来的~",
"天冷了,多穿衣服~"
]
colors = [
'lightpink', 'skyblue', 'lightblue', 'lavender', 'honeydew',
'bisque', 'mistyrose', 'aquamarine', 'oldlace', 'palegreen'
]
windows = []
def spawn_one(root, screen_w, screen_h):
"""随机位置弹出一个窗口"""
win = tk.Toplevel(root)
windows.append(win)
# 随机位置(允许重叠)
x = random.randint(0, max(0, screen_w - WINDOW_W))
y = random.randint(0, max(0, screen_h - WINDOW_H))
# 随机外观
win.geometry(f"{WINDOW_W}x{WINDOW_H}+{x}+{y}")
win.attributes("-topmost", True)
win.title("温馨提示")
tk.Label(
win,
text=random.choice(tips),
bg=random.choice(colors),
font=("微软雅黑", 16),
width=100,
height=20
).pack()
def random_spawn_loop(root, screen_w, screen_h, remaining):
if remaining <= 0:
return
spawn_one(root, screen_w, screen_h)
# 每次间隔随机变化
delay = random.randint(SPAWN_INTERVAL_MS // 2, SPAWN_INTERVAL_MS * 2)
root.after(delay, random_spawn_loop, root, screen_w, screen_h, remaining - 1)
def close_all(root):
"""关闭所有窗口"""
for w in windows:
try:
w.destroy()
except:
pass
try:
root.destroy()
except:
pass
def bind_space_to_close(root):
root.bind("<space>", lambda e: close_all(root))
if __name__ == "__main__":
root = tk.Tk()
root.withdraw()
bind_space_to_close(root)
sw, sh = root.winfo_screenwidth(), root.winfo_screenheight()
# 启动随机弹窗循环
random_spawn_loop(root, sw, sh, COUNT)
# 自动关闭
root.after(AUTO_CLOSE_MS, lambda: close_all(root))
root.mainloop()
爱心
import tkinter as tk
import random
import math
WINDOW_W, WINDOW_H = 250, 60
COUNT = 100
BASE_DELAY_MS = 15
TIME_JITTER_MS = 10
POS_JITTER_PX = 12
AUTO_CLOSE_MS = 12000
tips = [
"多喝水呀~", "保持微笑呀~", "每天都要元气满满~",
"记得吃早饭~", "好好爱自己~", "我想你了~",
"顺顺利利~", "早上好呀~", "今天过得开心吗~", "天冷了,多穿衣服~"
]
colors = [
'lightpink', 'skyblue', 'lightblue', 'lavender', 'honeydew',
'bisque', 'mistyrose', 'aquamarine', 'oldlace'
]
windows = []
def heart_xy(t: float):
"""爱心参数方程"""
x = 16 * math.sin(t) ** 3
y = 13 * math.cos(t) - 5 * math.cos(2 * t) - 2 * math.cos(3 * t) - math.cos(4 * t)
return (x, y)
def compute_heart_points(screen_w, screen_h, n):
"""生成逆时针爱心路径,从顶部(t=0)开始"""
ts = [0 + (2 * math.pi) * i / (n - 1) for i in range(n)] # 从 t=0 开始,逆时针走 0→2π
pts = [heart_xy(t) for t in ts]
# 坐标范围
xs, ys = [p[0] for p in pts], [p[1] for p in pts]
min_x, max_x = min(xs), max(xs)
min_y, max_y = min(ys), max(ys)
span_x, span_y = max_x - min_x, max_y - min_y
margin = 40
usable_w = max(200, screen_w - WINDOW_W - 2 * margin)
usable_h = max(200, screen_h - WINDOW_H - 2 * margin)
scale = min(usable_w / span_x, usable_h / span_y)
cx, cy = screen_w // 2, screen_h // 2
mapped = []
for x, y in pts:
sx = int(cx + (x - (min_x + span_x / 2)) * scale)
sy = int(cy - (y - (min_y + span_y / 2)) * scale)
sx -= WINDOW_W // 2
sy -= WINDOW_H // 2
sx += random.randint(-POS_JITTER_PX, POS_JITTER_PX)
sy += random.randint(-POS_JITTER_PX, POS_JITTER_PX)
sx = max(0, min(screen_w - WINDOW_W, sx))
sy = max(0, min(screen_h - WINDOW_H, sy))
mapped.append((sx, sy))
return mapped # 不需要再排序了,我们直接按 t 顺序生成
def spawn_one(root, pos):
win = tk.Toplevel(root)
windows.append(win)
x, y = pos
win.geometry(f"{WINDOW_W}x{WINDOW_H}+{x}+{y}")
win.attributes("-topmost", True)
win.title("温馨提示")
tk.Label(
win,
text=random.choice(tips),
bg=random.choice(colors),
font=("微软雅黑", 16),
width=30, height=3
).pack()
def spawn_heart_sequence(root, positions, idx=0):
if idx >= len(positions):
return
spawn_one(root, positions[idx])
delay = max(1, BASE_DELAY_MS + random.randint(-TIME_JITTER_MS, TIME_JITTER_MS))
root.after(delay, spawn_heart_sequence, root, positions, idx + 1)
def close_all(root):
for w in windows:
try: w.destroy()
except: pass
try: root.destroy()
except: pass
def bind_space_to_close(root):
root.bind("<space>", lambda e: close_all(root))
if __name__ == "__main__":
root = tk.Tk()
root.withdraw()
bind_space_to_close(root)
sw, sh = root.winfo_screenwidth(), root.winfo_screenheight()
positions = compute_heart_points(sw, sh, COUNT)
# 依次弹出(从上尖开始逆时针)
spawn_heart_sequence(root, positions)
# 10 秒后自动关闭
root.after(AUTO_CLOSE_MS, lambda: close_all(root))
root.mainloop()
太棒了
indonesia vacation packages Logan E. The ATV sunset tour was incredible — great photos and great vibes. https://linktr.ee/travelshopbooking
Keno’s probability is fascinating – so much relies on random draws! It’s cool to see games like free solitaire offer a different kind of mental challenge, instantly accessible without downloads – a nice break from number crunching!
It’s fascinating how gambling regulations have evolved! Seeing platforms like Nustar prioritize compliance-KYC, AML, data privacy-is crucial for trust. Check out nustar game login download apk for a secure experience – responsible gaming is key!
Sinagphcasino is aight, fam! They got a fair mix of games. Worth checking out if you’re looking for somewhere new to play. Give ’em a shot over at sinagphcasino
Alright, vaobong 1gom is the place! Seems like a good option, gonna test it out.
Gave m66bet a fair shot. Not too shabby, nice and easy to get started. What do you have to lose? Check it out yourself! m66bet
Need a reliable link to Bong88? linkvaobong88com seems to do the trick. Never had any problems accessing the site through it. Recommended, I’d say! Get the link here: linkvaobong88com
vaobong88com is solid if you wanna get into Bong88. I’ve had no issues! Check them now: vaobong88com
Alright guys, heard about trangchubong88? Been lookin’ for a reliable spot to get my Bong88 fix and this seems legit. Anyone else used it? Lemme know your experiences! Check it out here: trangchubong88
Alright, alright, alright… ph88bet is my betting hub. Good odds and a smooth experience overall. Give it a shot, huh? ph88bet
elpatrullero777 is cool. Seems like it is fairly similar to other sites, but it loads so easily. This alone is worth it when compared to the alternatives. Be safe and check it out elpatrullero777, and you won’t be let down!
BBQ999, alright, so it’s got a kind of strange name, but the site’s legit. Lots of different things to try out, which is always a plus. Check out bbq999 for something different.
So, I gave jilicrown41 a try. It’s got a decent vibe, might be worth checking out if you’re looking for something new. It’s got its own thing going on. Have a look: jilicrown41
Easy login at jilibet04login.com! Straightforward platform and easy to figure out, especially if you’re familiar with online gaming. I enjoyed it! Visit jilibet04login
Okay, tried out ku3933157. Not bad, not bad at all. Games were fair, pretty quick payouts too. Giving it a thumbs up this month, check it out ku3933157
This creative tkinter code brings delightful UX through randomized wellness prompts! The minimalist interface design reminds me of efficient embedded systems like pico claw risc-v, proving that small code footprints can deliver meaningful user experiences. Fantastic example of Python’s versatility for playful desktop applications.
Casibom 432 is a great website, if you want to have fun. You can try it, here is the website: casibom 432
Jilihot777, I’m feeling lucky today! Gonna try my hand at hitting that jackpot. Come on, lucky sevens! Lets goo jilihot777
Mantap jiwa! Borneo303 emang tempatnya SV388 online paling seru. Gampang banget mainnya, dan yang penting, WD lancar jaya! Cobain deh, bro! sv388 online borneo303
Hey guys, checked out 188jl the other day. Not bad, pretty smooth experience. Definitely worth a look if you’re looking for something new. Check it out here 188jl
Hey, has anyone tried 777colorgame? I did, and it was kinda fun. Nothing groundbreaking but good for wasting some time. Here’s the link 777colorgame
Hey there peeps! Quick one about ‘a9’. Tried it out. Solid, not amazing, but reliable enough for a good chill sesh. Check it out if you’re keen. a9