效果图
代码
import tkinter as tk
import random
import threading
import timedef dow():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("220x50" + "+" + str(a) + "+" + str(b))tk.Label(window,text='我想你了!',bg='pink',font=('楷体',18),width=25,height=4).pack()window.mainloop()threads =[]
for i in range(5):t = threading.Thread(target=dow)threads.append(t)time.sleep(0.01)threads[i].start()