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

定义窗口函数

绑定点击事件

相关推荐
小苹果13571 小时前
阿里云mysql数据丢失,如何通过服务器备份在其他服务器上恢复数据,并获取mysql丢失数据,完成mysql数据恢复
服务器·mysql·阿里云
许白掰1 小时前
Linux入门篇学习——Linux 工具之 make 工具和 makefile 文件
linux·运维·服务器·前端·学习·编辑器
hrrrrb2 小时前
【TCP/IP】12. 文件传输协议
服务器·网络·tcp/ip
木头左2 小时前
逻辑回归的Python实现与优化
python·算法·逻辑回归
quant_19863 小时前
R语言如何接入实时行情接口
开发语言·经验分享·笔记·python·websocket·金融·r语言
安全系统学习5 小时前
网络安全之RCE分析与利用详情
服务器·网络·安全·web安全·系统安全
longze_75 小时前
Ubuntu连接不上网络问题(Network is unreachable)
linux·服务器·ubuntu
Dirschs5 小时前
【Ubuntu22.04安装ROS Noetic】
linux·ubuntu·ros
qianshanxue115 小时前
ubuntu 操作记录
linux