通过Python实现自动弹窗,恶搞小兄弟,谨慎使用,代码如下(需要安装引用的几个依赖):
import tkinter as tk import random import threading import time def boom(): window = tk.Tk() width = window.winfo_screenwidth() height = window.winfo_screenheight() a = random.randrange(0, width) b = random.randrange(0, height) window.title('我是你爸爸!') #弹窗的标题 window.geometry("200x50" + "+" + str(a) + "+" + str(b)) tk.Label(window, text='我是你爸爸', bg='green', font=('宋体', 17), width=20, height=4).pack() #可以设置弹窗的字体,高度和宽度,弹窗中的文本内容 window.mainloop() threads = [] for i in range(30): #可以设置弹窗的个数,此时设置为弹出30个 t = threading.Thread(target=boom) threads.append(t) time.sleep(0.1) threads[i].start()
效果如下:
可以将Python打包成exe,直接执行exe即可,具体操作可查看另一篇文章
https://blog.csdn.net/gcs12345/article/details/127618188?spm=1001.2014.3001.5502