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

定义窗口函数

绑定点击事件

相关推荐
@syh.8 分钟前
【linux】多线程
linux
RisunJan11 分钟前
Linux命令-man(查看Linux中的指令帮助)
linux·运维·服务器
REDcker13 分钟前
CentOS 与主流 Linux 发行版:版本与时间表(年表)
linux·运维·centos
万粉变现经纪人16 分钟前
如何解决 pip install cx_Oracle 报错 未找到 Oracle Instant Client 问题
数据库·python·mysql·oracle·pycharm·bug·pip
bai_lan_ya16 分钟前
使用linux的io文件操作综合实验_处理表格
linux·服务器·算法
sw12138916 分钟前
使用Plotly创建交互式图表
jvm·数据库·python
2301_8101609519 分钟前
如何为开源Python项目做贡献?
jvm·数据库·python
若惜20 分钟前
selenium自动化测试web自动化测试 框架封装Pom
前端·python·selenium
扁舟·TF20 分钟前
VirtuaBox: 修改 Host-Only 网络的 IP 地址
服务器·网络·tcp/ip
weixin_4577600026 分钟前
基于pytorch实现LPR模型车牌识别
人工智能·pytorch·python·深度学习·lpr