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 小时前
LVS章节
linux
liu****6 小时前
5.Linux CGroups 资源控制实战(CPU+内存)超详细教程
linux·运维·服务器·docker
礼拜天没时间.8 小时前
Docker 部署分布式 Hadoop(超详细实战版)
linux·hadoop·分布式·docker·容器
徐同保15 小时前
python异步函数语法解析,async with ... as ...语法解析
数据库·python·oracle
m***066815 小时前
SpringBoot项目中读取resource目录下的文件(六种方法)
spring boot·python·pycharm
eWidget15 小时前
数据可视化进阶:Seaborn 柱状图、散点图与相关性分析
数据库·python·信息可视化·kingbase·数据库平替用金仓·金仓数据库
IP搭子来一个16 小时前
2026年动态IP代理怎么选:共享好还是独享好?
服务器·网络协议·tcp/ip
比奇堡派星星16 小时前
awk命令
linux·运维·服务器
WW、forever16 小时前
【服务器】上传百度网盘数据至服务器
运维·服务器