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

定义窗口函数

绑定点击事件

相关推荐
xwill*1 小时前
分词器(Tokenizer)-sentencepiece(把训练语料中的字符自动组合成一个最优的子词(subword)集合。)
开发语言·pytorch·python
CheungChunChiu1 小时前
Linux 内核设备模型与驱动框架解析 ——以 rk-pcie 为例
linux·运维·ubuntu
咖啡の猫1 小时前
Python列表的查询操作
开发语言·python
Chiandra_Leong1 小时前
Python-Pandas、Numpy
python·pandas
BoBoZz191 小时前
ParametricObjectsDemo多种参数曲面展示及面上部分点法线展示
python·vtk·图形渲染·图形处理
列逍2 小时前
Linux进程(三)
linux·运维·服务器·环境变量·命令行参数
quikai19812 小时前
python练习第三组
开发语言·python
水天需0102 小时前
VS Code Ctrl+Shift+V 预览 Markdown 无效的解决方案
linux
ULTRA??3 小时前
初学protobuf,C++应用例子(AI辅助)
c++·python
CHANG_THE_WORLD3 小时前
Python 字符串全面解析
开发语言·python