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

定义窗口函数

绑定点击事件

相关推荐
Flash.kkl3 分钟前
Linux——进程信号
运维·服务器
苏宸啊1 小时前
Linux权限
linux·运维·服务器
多米Domi0111 小时前
0x3f第33天复习 (16;45-18:00)
数据结构·python·算法·leetcode·链表
我是小疯子662 小时前
Python变量赋值陷阱:浅拷贝VS深拷贝
java·服务器·数据库
freepopo2 小时前
天津商业空间设计:材质肌理里的温度与质感[特殊字符]
python·材质
森叶2 小时前
Java 比 Python 高性能的原因:重点在高并发方面
java·开发语言·python
xqhoj2 小时前
Linux——make、makefile
linux·运维·服务器
张童瑶2 小时前
Linux 在线安装编译Python3.11
linux·运维·python3.11
Shi_haoliu2 小时前
SolidTime 在 Rocky Linux 9.5 上的完整部署流程
linux·运维·nginx·postgresql·vue·php·laravel
lifejump2 小时前
Pikachu | XXE
服务器·web安全·网络安全·安全性测试