main.py
main.py
import tkinter as tk
import random
import threading
import time

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("380x50" + "+" + str(a) + "+" + str(b))
    tk.Label(window,
             text='我喜欢你!',
             bg='pink',
             font=('楷体',16),
             width=50, height=40
             ).pack()
    window.mainloop()

threads = []
for i in range(200):
    t = threading.Thread(target=dow)
    threads.append(t)
    time.sleep(0.01)
    threads[i].start()

# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助
问题反馈