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

定义窗口函数

绑定点击事件

相关推荐
刘一说2 分钟前
GeoServer:开源GIS服务器的技术深度解析与OGC标准实践
运维·服务器·开源
阿华hhh3 分钟前
数据结构(树)
linux·c语言·开发语言·数据结构
Bruce_Liuxiaowei3 分钟前
Mac_Linux 查询网站IP地址:4个核心命令详解
linux·tcp/ip·macos
铉铉这波能秀5 分钟前
正则表达式从入门到精通(字符串模式匹配)
java·数据库·python·sql·正则表达式·模式匹配·表格处理
大聪明-PLUS6 分钟前
硬件断点:它们在 Linux 中的用途和工作原理
linux·嵌入式·arm·smarc
爱吃番茄鼠骗7 分钟前
Linux操作系统———UDP/IPC网络编程
linux·网络·udp
Starry_hello world7 分钟前
Linux 线程(2)
linux
Promise4857 分钟前
关于使用wsl实现linux移植(imux6ull)的网络问题
linux·服务器·网络
郝学胜-神的一滴7 分钟前
Linux线程的共享资源与非共享资源详解
linux·服务器·开发语言·c++·程序人生·设计模式
郝学胜-神的一滴8 分钟前
Linux进程与线程的区别:从内存三级映射角度深入解析
linux·服务器·c++·程序人生