


import tkinter as tk
import math
def show_popups():
total = 300
for i in range(total):
t = 2 * math.pi * i / total
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)
cx = root.winfo_screenwidth() // 2
cy = root.winfo_screenheight() // 2
px = cx + int(x * 20)
py = cy - int(y * 20)
popup = tk.Toplevel(root)
popup.title("❤️")
popup.geometry(f"200x100+{px}+{py}")
popup.attributes('-topmost', True)
label = tk.Label(popup, text="你是猪!", font=("Arial", 18, "bold"), fg="red")
label.pack(expand=True)
root.update()
def wrong_answer():
msg = tk.Toplevel(root)
msg.title("❌")
msg.geometry("300x150")
msg.attributes('-topmost', True)
msg.resizable(False, False)
# 居中显示
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
mx = (ws - 300) // 2
my = (hs - 150) // 2
msg.geometry(f"300x150+{mx}+{my}")
tk.Label(msg, text="答错了!", font=("Arial", 24, "bold"), fg="red").pack(pady=20)
tk.Label(msg, text="再选择一次", font=("Arial", 16), fg="gray").pack()
root = tk.Tk()
root.title("你是猪吗?")
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = (ws - 400) // 2
y = (hs - 300) // 2
root.geometry(f"400x300+{x}+{y}")
root.resizable(False, False)
root.protocol("WM_DELETE_WINDOW", lambda: None)
label = tk.Label(root, text="你是猪吗?", font=("Arial", 28, "bold"))
label.pack(expand=True)
btn_frame = tk.Frame(root)
btn_frame.pack(pady=20)
tk.Button(btn_frame, text="我是", command=show_popups,
width=10, height=2, bg="#ff6b6b", fg="white", font=("Arial", 12)).pack(side=tk.LEFT, padx=15)
tk.Button(btn_frame, text="我不是", command=wrong_answer,
width=10, height=2, bg="#4ecdc4", fg="white", font=("Arial", 12)).pack(side=tk.RIGHT, padx=15)
root.mainloop()