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

定义窗口函数

绑定点击事件

相关推荐
IMPYLH6 分钟前
Linux 文件检索:find、locate、grep 与 which 实战指南
linux·运维·服务器
西索斯coding18 分钟前
Claude Code 工具调用返回空怎么办?claude-opus-5.5 的 input_schema 校验踩坑记录与修复方案
服务器·前端·javascript·ai
坊钰26 分钟前
【LangGraph框架入门级】4. 支持联网搜索的智能代理系统
python·ai编程·langgraph
运维@小兵39 分钟前
安装Pycharm并破解
ide·python·pycharm
冬、不眠的夜1 小时前
Nuitka 将 python 程序编译成 exe 指南
开发语言·python
脚踏实地,坚持不懈!1 小时前
Linux 内存回收机制:水位线、kswapd 与 Direct Reclaim
linux·jvm·算法
SKH.1 小时前
Linux驱动-key、中断
linux·运维·服务器
小龙报1 小时前
【零到全栈】从扩展名到终端实操,打通 Linux 基础
linux·ubuntu·云原生·职场和发展·创业创新·学习方法·程序员创富
范中勤1 小时前
Python Asyncio 协程与 LLM 异步并发原理技术文档(与 Java 对比|彻底澄清所有误区)
python·llm·协程·并发编程·asyncio
Dmz丶1 小时前
前端转 AI 100 天 Day 21:FastAPI 入门——从命令行到 HTTP 服务
python