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

定义窗口函数

绑定点击事件

相关推荐
@HNUSTer3 分钟前
Python数据可视化科技图表绘制系列教程(七)
python·数据可视化·科技论文·专业制图·科研图表
shizidushu4 分钟前
How to work with merged cells in Excel with `openpyxl` in Python?
python·microsoft·excel·openpyxl
代码炼金术士11 分钟前
服务器更换jar包,重启后端服务
服务器·jar
郝学胜-神的一滴13 分钟前
深入探索 Python 元组:从基础到高级应用
运维·服务器·开发语言·python·程序人生
CheungChunChiu16 分钟前
嵌入式 Linux 启动机制全解析:从 Boot 到 Rootfs
linux·运维·服务器·ubuntu·uboot·boot·extboot
白鹭17 分钟前
nginx(介绍+源码安装+平滑升级和回滚)
linux·运维·服务器·nginx·回滚·平滑升级
技术程序猿华锋20 分钟前
深度解码OpenAI的2025野心:Codex重生与GPT-5 APIKey获取调用示例
人工智能·vscode·python·gpt·深度学习·编辑器
DTS小夏41 分钟前
Linux 系统 + IDEA+Scala 插件:新手进阶开发指南
linux·scala·intellij-idea
老黄编程1 小时前
--gpu-architecture <arch> (-arch)
linux·人工智能·机器学习
肖爱Kun1 小时前
LINUX中USB驱动架构—URB请求块
linux·驱动