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

定义窗口函数

绑定点击事件

相关推荐
来自远方的老作者17 分钟前
第7章 运算符-7.1 算术运算符
开发语言·数据结构·python·算法·算术运算符
tq6J5Yg1421 分钟前
windows10本地部署openclaw
前端·python
gwjcloud27 分钟前
Frp内网穿透
linux·运维·服务器
MwEUwQ3Gx35 分钟前
常见Linux权限提升笔记
linux·运维·笔记
bIo7lyA8v38 分钟前
如何用SSH访问远程服务器上的内网服务(如:MySQL、Redis、Kafka)?
服务器·mysql·ssh
pl4H522a639 分钟前
Python 高效实现 Excel 转 TXT 文本
java·python·excel
数据知道1 小时前
claw-code 源码详细分析:Compaction 前置课——上下文压缩在接口层要预留哪些旋钮,避免后期全局返工?
python·ai·claude code
小邓睡不饱耶1 小时前
花店花品信息管理系统开发实战:Python实现简易门店管理系统
服务器·python·microsoft
witAI1 小时前
手机生成剧本杀软件2025推荐,创新剧情设计工具助力创作
人工智能·python
ken22321 小时前
安装问题@ ubuntu 24.04 :efi 磁盘分区,挂载
linux·运维·ubuntu