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

定义窗口函数

绑定点击事件

相关推荐
HHHHH1010HHHHH4 分钟前
JavaScript中利用IIFE创建私有命名空间的经典方案
jvm·数据库·python
韩明君5 分钟前
OpenClaw安全部署实现
linux·人工智能·安全·debian·本地部署·ai agent·openclaw
干洋芋果果9 分钟前
前端学python
开发语言·前端·python
YJlio10 分钟前
1 1.2 Windows 账户的分类:管理员 / 标准 / 来宾 + 微软账户 vs 本地账户
人工智能·python·microsoft·ai·chatgpt·openai·agent
代码中介商16 分钟前
Linux 文件操作系统调用完全指南:从 open 到 close
linux·运维·服务器
篮子里的玫瑰18 分钟前
Python与网络爬虫——列表与元组
开发语言·爬虫·python
被摘下的星星21 分钟前
传输控制协议(TCP)
服务器·网络·tcp/ip
knight_9___22 分钟前
RAG面试篇8
人工智能·python·面试·agent·rag
想拿大厂offer23 分钟前
【Linux】权限
linux·服务器
2301_7965885023 分钟前
Go语言如何压缩文件_Go语言gzip压缩教程【基础】
jvm·数据库·python