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

定义窗口函数

绑定点击事件

相关推荐
橘子真甜~1 分钟前
Linux基础3-基础工具3(make,makefile,gdb详解)
linux·运维·服务器·makefile·make·gbd
z are5 分钟前
包含 Python 与 Jupyter的Anaconda的下载安装
开发语言·python·jupyter
傻啦嘿哟20 分钟前
在Excel中通过Python运行公式和函数实现数据计算
开发语言·python·excel
使者大牙20 分钟前
【PyTorch单点知识】深入了解 nn.ModuleList和 nn.ParameterList模块:灵活构建动态网络结构
人工智能·pytorch·python·深度学习
TIF星空33 分钟前
【从0开始在CentOS 9中安装redis】
linux·运维·服务器·经验分享·redis·笔记·centos
qh0526wy35 分钟前
量化交易的个人见解
python
元素之窗35 分钟前
CentOS 系统设置与维护教程
linux·运维·centos
qq_426938481 小时前
git-fork操作指南
git·python
matrixlzp1 小时前
Python 解析 JSON 数据
python
小李很执着1 小时前
【深度智能】:迈向高级时代的人工智能全景指南
人工智能·python·深度学习·算法·机器学习·语言模型