源码如下:
import tkinter as tk
import threading
import time
import random
def 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("200x50"+"+"+str(a)+"+"+str(b))
tk.Label(window,text='亲爱的,七夕节快乐!',bg='pink',fg='white',font=('楷体',14,),width=20,height=2).pack()
window.mainloop()
threads=[]
for i in range(10):
t = threading.Thread(target=dow)
threads.append(t)
time.sleep(0.1)
threads[i].start()
关注个人公众号【茶哩茶】获取python核心知识学习资料