其他
用Python把新婚祝福打满公屏!
适逢金秋成佳偶,稻花香里天作合。2020年10月7日,涛门又迎来了一桩喜事——司海涛与其爱人李钰燕相伴相依走进婚姻的殿堂。在此,爬虫俱乐部全体成员向海涛师兄送上最诚挚的祝福,祝愿你们幸福美满,永结同心,白头偕老天地春,恩爱一生永相伴!撒花~
逢此佳节,我们也以自己的方式为这对才子与佳人打call,用Python把对师兄的祝福真·打满公屏,祝愿二人同量天地宽,共渡日月长!
上述效果的实现过程如下:
代码
import tkinter as tk
import random
import threading
import time
def zhufu():
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("300x50"+"+"+str(a)+"+"+str(b))
#设置祝福文案
list=["新婚快乐!","白头偕老!","百年好合!","永结同心!","才子配佳人!","幸福美满","天作之合","前生注定,喜结良缘","恭贺新婚之禧!","郎才女貌","佳偶天成","永浴爱河","天生一对","恭喜你们步入爱的殿堂!","幸福美满,共谐连理","祝福一对佳人真心相爱","长长久久~~","恩恩爱爱"]
tk.Label(window,
text=random.sample(list,1),
bg='LavenderBlush',
font=('楷体', 17),
width=25, height=2
).pack()
window.mainloop()
threads = []
#设置需要的弹框数目
for i in range(100):
t = threading.Thread(target=zhufu)
threads.append(t)
time.sleep(0.1)
threads[i].start()
最后,再次祝福这对才子与佳人新婚之喜,百年好合,此爱永恒~