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

定义窗口函数

绑定点击事件

相关推荐
zhuyan1082 分钟前
【AI编程】aider安装记录
linux·运维·ai编程
书山有鹿25 分钟前
MaxKB v2.7.0 Rocky Linux 9 部署手册
linux·运维·maxkb·rockylinux 9
Mapleay28 分钟前
ALSA PCM 数据搬运模式
linux
飞Link28 分钟前
LangChain 核心链式架构演进史:从顺序链到企业级路由兜底实战
python·架构·langchain
啥咕啦呛33 分钟前
java打卡学习3:ArrayList扩容机制
java·python·学习
编程之升级打怪35 分钟前
用排他锁来实现Python语言的变量值更新
开发语言·python
打乒乓球只会抽37 分钟前
【无标题】
python
路小雨~1 小时前
Django 学习笔记:从入门到项目开发的完整梳理
笔记·python·学习·django
Elastic 中国社区官方博客1 小时前
使用 ES|QL 变量控件将仪表板转变为调查工具
大数据·运维·服务器·数据库·elasticsearch·搜索引擎·全文检索
Yana.nice1 小时前
Ansible 常用模块
网络·python·ansible