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

定义窗口函数

绑定点击事件

相关推荐
Chen--Xing几秒前
2025鹏城杯 -- Crypto -- RandomAudit详解
python·密码学·ctf·鹏城杯
了一梨7 分钟前
外设与接口:按键输入 (libgpiod)
linux·c语言
一瞬祈望24 分钟前
PyTorch 图像分类完整项目模板实战
人工智能·pytorch·python·深度学习·分类
坐吃山猪30 分钟前
BrowserUse12-源码-MCP模块
python·llm·playwright·browser-use
昔时扬尘处34 分钟前
【Files Content Replace】文件夹文件内容批量替换自动化测试脚本
c语言·python·pytest·adi
爱潜水的小L1 小时前
自学嵌入式day30,回收进程
java·linux·服务器
咖啡の猫1 小时前
Python字典的查询操作
数据库·python·c#
smile_Iris1 小时前
Day 38 GPU训练及类的call方法
开发语言·python
水天需0101 小时前
PS 例程大全
linux
源宇宙十三站1 小时前
Linux故障诊断系列2.3-诊断系统启动问题-Server启动失败该如何处理
linux