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

定义窗口函数

绑定点击事件

相关推荐
12345,catch a tiger4 分钟前
虚拟机ubuntu安装Vmware Tools
linux·运维·ubuntu
好家伙VCC14 分钟前
**发散创新:基于Python与ROS的机器人运动控制实战解析**在现代机器人系统开发中,**运动控制**是实现智能行为的核心
java·开发语言·python·机器人
2401_8274999914 分钟前
python项目实战09-AI智能伴侣(ai_partner_2-3)
开发语言·python
派葛穆17 分钟前
汇川PLC-Python与汇川easy521plc进行Modbustcp通讯
开发语言·python
✎ ﹏梦醒͜ღ҉繁华落℘18 分钟前
Makefile -GNU和MakeFile关系(二)
服务器·gnu
凉、介24 分钟前
别再把 PCIe 的 inbound/outbound、iATU 和 eDMA 混为一谈
linux·笔记·学习·嵌入式·pcie
辰风沐阳38 分钟前
OpenClaw 安装教程(Ubuntu 24.04 Desktop)
linux·ubuntu
代码小书生43 分钟前
Matplotlib,Python 数据可视化核心库!
python·信息可视化·matplotlib
嘿嘿嘿x31 小时前
Linux记录过程
linux·开发语言
默 语1 小时前
Records、Sealed Classes这些新特性:Java真的变简单了吗?
java·开发语言·python