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

定义窗口函数

绑定点击事件

相关推荐
lifewange2 分钟前
关于进程的 Linux 命令有哪些?
linux·运维·服务器
计算机程序设计小李同学6 分钟前
基于 Flask 的养猪场信息模拟系统
后端·python·flask
三两肉9 分钟前
Linux 网络包的 “快递分拣”:从发送到接收的内核协作全景
linux·网络·计算机网络·tcp
Iridescent112116 分钟前
Iridescent:Day38
python
熬夜敲代码的小N16 分钟前
2026 职场生存白皮书:Gemini Pro 实战使用指南
人工智能·python·ai·职场和发展
M1582276905527 分钟前
串口设备联网利器!SG-TCP232-110 单通道串口服务器,让老旧设备秒变智能终端
运维·服务器·单片机
semantist@语校28 分钟前
第五十八篇|从城市节律到制度密度:近畿日本语学院的数据建模与关西语校结构工程
大数据·服务器·数据库·人工智能·百度·ai·知识图谱
Franklin28 分钟前
移植一个Pycharm的复杂项目:
ide·python·pycharm
94621931zyn633 分钟前
外观设置 - Cordova 与 OpenHarmony 混合开发实战
笔记·python
彼岸花开了吗40 分钟前
构建AI智能体:六十五、模型智能训练控制:早停机制在深度学习中的应用解析
人工智能·python