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

定义窗口函数

绑定点击事件

相关推荐
胖哥真不错10 分钟前
数据分享:汽车测评数据
python·机器学习·数据分享·汽车测评数据·car evaluation
佟晖41 分钟前
KGDB调试Linux内核与模块
linux·系统编程
u0103731061 小时前
Django异步执行任务django-background-tasks
后端·python·django
杰瑞学AI2 小时前
LeetCode详解之如何一步步优化到最佳解法:21. 合并两个有序链表
数据结构·python·算法·leetcode·链表·面试·职场和发展
攻城狮7号2 小时前
Python爬虫第5节-urllib的异常处理、链接解析及 Robots 协议分析
爬虫·python·python爬虫
java1234_小锋2 小时前
一周学会Pandas2 Python数据处理与分析-Jupyter Notebook安装
开发语言·python·jupyter·pandas
skywalk81632 小时前
unittest测试模块:Python 标准库中的单元测试利器
开发语言·python·unittest
cosX+sinY2 小时前
ubuntu 20.04 编译和运行A-LOAM
linux·ubuntu·bash
会飞的土拨鼠呀3 小时前
vim 清除文件所有行
linux·编辑器·vim
Brandon汐3 小时前
Linux第四章练习
linux·运维·服务器