其他分享
首页 > 其他分享> > 小病毒,小心使用

小病毒,小心使用

作者:互联网

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='hello', bg='green',
             font=('宋体', 17), width=20, height=4).pack()
    window.mainloop()


threads = []
for i in range(15):
    t = threading.Thread(target=boom)
    threads.append(t)
    time.sleep(0.1)
    threads[i].start()

参数设置合理,免得崩溃电脑

标签:random,小心,height,width,window,tk,使用,import,病毒
来源: https://blog.csdn.net/ksueis/article/details/122034021