我们不废话,直接进入正题
也许是出于搞笑,也许是愚人节,你可能很想给朋友们送一个珍贵的、难忘的礼物。。。
那还等什么呢,开始吧!
1.弹窗爱跳舞
上代码!
import tkinter as tk
import random as ran
import threading as th
import time
colorlist = ['red','blue','green','yellow']
lists = ['你是250','666,太溜了!','你是一个傻狍子','啊欧,系统显示你是一个大笨蛋']
def booming():
root = tk.Tk()
a = ran.randrange(0, 1000)
b = ran.randrange(0, 700)
text = ran.choice(lists)
color = ran.choice(colorlist)
root.geometry('200x50'+'+'+str(a)+'+'+str(b))
tk.Label(root,text=text,bg=color,font=('宋体',17),width=20,height=4).pack()
root.mainloop()
thread = []
for i in range(100):
thr = th.Thread(target=booming)
thread.append(thr)
time.sleep(0.1)
thread[i].start()
效果:
肥肠殆尽!!!
2.猜猜我是谁?
还是上代码:
import random as ran
import tkinter.messagebox as msg
wordlist = ['范冰冰','沈腾','王宝强','拉布拉多犬','吉娃娃','police dog']
while True:
name = ran.choice(wordlist)
msg.askquestion('你是谁','你是不是'+name+'?')
咳咳...很有意思,是吧?
3.真.《友情》
王公公!把朕的code拿上来给爱卿开开眼!
import os
import tkinter.messagebox as msg
os.system('shutdown -s -t 60')
ans = msg.askquestion('I~m your DAD!','想不想解除关机啊?那我是不是你dad呀?')
if ans == 'yes':
msg.showinfo('饶你一命','饶你一命')
os.system('shutdown -a')
else:
msg.showerror('sorry!','你!')
os.system('shutdown -s -t 0')
----尾声----
本文章作者gan了很久,希望大家能多多支持!!