python恶搞无限弹窗脚本

python恶搞无限弹窗代码;

弹窗可以关闭,但是每次关闭都会增加一个出现;

例如关闭一个弹窗会出现两个弹窗;

初始化出现20个弹窗;

部分核心代码

python 复制代码
def on_close(top, root):
    global window_count
    # 关闭当前窗口
    top.destroy()
    window_count -= 1
    # 创建两个新窗口
    create_popups(root, 3)


def create_popup(root):
    global window_count
    if window_count >= 0:
        top = tk.Toplevel(root)
        width = 250
        height = 100
        screenwidth = root.winfo_screenwidth()
        screenheight = root.winfo_screenheight()
        x = ra.randint(0, screenwidth - width)
        y = ra.randint(0, screenheight - height)
        top.title("Thank you!")
        top.geometry(f"{width}x{height}+{x}+{y}")
        top.attributes('-topmost', 1)  # 确保窗口总是在最前面
        tk.Label(top, text='Your computer has been taken over by me', fg='white', bg='black', font=("Comic Sans MS", 9), width=40, height=20).pack()
        # 禁止窗口大小调整
        top.resizable(False, False)
        # 绑定关闭事件
        top.protocol("WM_DELETE_WINDOW", lambda t=top: on_close(t, root))
        window_count += 1

定义窗口函数

绑定点击事件

相关推荐
小北方城市网1 分钟前
GEO 智变新篇:质效双升 + 责任共生,打造 AI 时代本地商业长效增长引擎
大数据·人工智能·python·数据库架构
yueguangni5 分钟前
centos7虚拟机nat模式连接不上xshell方法分享
linux·运维·服务器
wadesir8 分钟前
解决VSCodeServer在CentOS 7上运行问题:glibc 2.17升级与内核优化指南(2025最新版)
linux·运维·centos
Hello_wshuo16 分钟前
锅炉温控系统优化
linux·python·物联网
weixin_4707403621 分钟前
python生成环境部署
开发语言·python
piaopiaolanghua22 分钟前
Python中的SGP4轨道预报库
python·sgp4
Eiceblue22 分钟前
Python 实现 CSV 转 TXT 格式 (单文件 + 批量处理)
开发语言·python·visual studio code
Iridescent112123 分钟前
Iridescent:Day49
python
阿巴~阿巴~37 分钟前
TCP性能优化秘籍:延迟应答、捎带确认与粘包破解之道
运维·服务器·网络·网络协议·udp·tcp
HuaYi_Sir38 分钟前
i.MX6ULL移植uboot Linux buildroot(二)
linux·运维·服务器