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

定义窗口函数

绑定点击事件

相关推荐
昌原的儿子LEO1 分钟前
【Linux网络编程】TCP套接字核心函数详解|三次握手|send/recv/listen/accept接口梳理
linux·网络·tcp/ip
实心儿儿3 分钟前
Linux —— 五种IO模型与非阻塞IO
运维·服务器
筝筝ba8 分钟前
extended/factory_reset.robot
linux·运维·服务器·网络·网络协议·p2p
wangduqiang74712 分钟前
如何借助AI申请专利不依靠代理机构
linux
SelectDB技术团队13 分钟前
StarRocks 适合做日志分析吗?
大数据·数据结构·后端·python·doris·日志分析·starrock
优化Henry13 分钟前
5G网络切片之S-NSSAIlist相关参数解析
运维·服务器·网络·笔记·学习·信息与通信
子有内涵19 分钟前
【Linux】C++ 实现可扩展 TCP 服务器|回响、字典、远程命令
linux·运维·服务器
新兴AI民工25 分钟前
# 【Linux内核三十六】进程管理模块:CFS负载均衡(一):sched_domain与sched_group层级构建
linux·运维·负载均衡
pride.li29 分钟前
WSL教程-WSL安装与配置Ubuntu
linux
luj_176829 分钟前
毒素驱动的生物自毁机制探析
服务器·c语言·开发语言·经验分享·算法