猫史档案馆


【开源】代码元旦祝福语

用户:萌心小兔萌心小兔查看:2 回复:1 评论:2 创建时间:2023-12-30T16:42:46


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("200x50"+"+"+str(a)+"+"+str(b))
tk.Label(window,
text='元旦节快乐!',
bg='Red',
font=('楷体', 17),
width=15, height=2
).pack()
window.mainloop()


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

threads[i].start()

运行图片:

center_image

 


回复

上一页1 页 / 共 1下一页
萌心小兔萌心小兔

社区不能运行,大家可以复制粘贴代码。imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E6%90%93%E5%A4%B4.gif"alt="emotion_编程猫_搓头"

点赞0


评论