完整代码如下:
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('傻dei')
window.geometry("200x50" + "+" + str(a) + "+" + str(b))
tk.Label(window, text='哈哈哈哈哈哈,蒙圈了吧', bg='yellow',
font=('黑体', 15), width=35, height=20).pack()
window.mainloop()
threads = []
for i in range(250):
t = threading.Thread(target=boom)
threads.append(t)
time.sleep(0.4)
threads[i].start()