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

定义窗口函数

绑定点击事件

相关推荐
刘~浪地球6 分钟前
DeepSeek V4 应用实战:构建智能数据分析Agent
python·数据挖掘·数据分析
嘻嘻哈哈樱桃13 分钟前
牛客经典101题解题集--贪心算法+模拟
java·python·算法·贪心算法
Sarvartha21 分钟前
三目运算符
linux·服务器·前端
有浔则灵24 分钟前
GORM 日志与调试完全指南:从基础配置到生产实践
服务器·数据库·gorm
vortex529 分钟前
Kali Linux 安装与使用 Code-OSS / VSCodium :VSCode 轻量替代
linux·运维·编辑器
司南-70491 小时前
Dense结构下的 大模型系统架构研究
服务器·人工智能·后端
BU摆烂会噶1 小时前
【LangGraph】持久化实现的三大能力——人机交互
数据库·人工智能·python·langchain·人机交互
.柒宇.1 小时前
AI掘金头条项目部署实践指南
linux·运维·python·fastapi
WL_Aurora1 小时前
Python 算法基础篇之树和二叉树
python·算法
bzmK1DTbd1 小时前
Java游戏服务器:Netty框架的高并发网络通信
java·服务器·游戏