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

定义窗口函数

绑定点击事件

相关推荐
TiDB 社区干货传送门14 小时前
【附操作指南】从 Oceanbase 增量数据同步到 TiDB
linux·服务器·数据库·tidb·oceanbase
沟通qq 87622396514 小时前
三层电梯的PLC控制实战:从IO表到仿真联调
python
Dxy123931021614 小时前
python如何去掉字符串中最后一个字符
开发语言·python
红辣椒...14 小时前
安装next-ai-draw-io
linux·运维·服务器
遇见火星14 小时前
Linux性能调优:详解磁盘工作流程及性能指标
linux·运维·服务器
专注VB编程开发20年14 小时前
多线程解压安装ZIP,EXE分析-微软的MSI安装包和 .NET SDK EXE
linux·运维·服务器·microsoft·.net
Dxy123931021614 小时前
Python类入门:用“汽车工厂”理解面向对象编程
python
拉普拉斯妖10814 小时前
DAY35 模型可视化与推理
python
无垠的广袤14 小时前
【启明云端 WT9932S3-Nano 开发板】介绍、环境搭建、工程测试
python·单片机·嵌入式硬件
方安乐14 小时前
linux常用命令
linux·运维·服务器