最近闲着无聊,写了个简单的无限弹窗,给你们看看
# -*-coding:utf-8 -*-
# @Time :2022/5/26 20:45
# 弹窗恶搞程序
import tkinter as tk
import random
import threading
import time
import winsound
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('Windows系统提示')
window.geometry("400x100" + "+" + str(a) + "+" + str(b))
# 设置告警内容
tk.Label(window, text='错误,Windows正遭受蔡徐坤和鸡你太美攻击!', bg='red',
font=('宋体', 17), width=40, height=4).pack()
winsound.MessageBeep(winsound.MB_ICONASTERISK)
window.mainloop()
def lu():
TK = tk.Tk()
width = TK.winfo_screenwidth()
height = TK.winfo_screenheight()
a = random.randrange(0, width)
b = random.randrange(0, height)
TK.title("来自蔡徐坤的嘲讽")
TK.geometry("400x100" + "+" + str(a) + "+" + str(b))
tk.Label(TK, text='鸡你太美!!!', bg='purple',
font=('宋体', 17), width=40, height=4).pack()
winsound.MessageBeep(winsound.MB_ICONASTERISK)
# 显示窗口弹窗
TK.mainloop()
if __name__ == '__main__':
# 采用多线程方式,
threads = []
for i in range(100):
t = threading.Thread(target=boom)
p = threading.Thread(target=lu)
threads.append(t)
threads.append(p)
time.sleep(0.5)
threads[i].start()
弹窗内容你们可以自己写就在tk.Label(TK, text='鸡你太美!!!', bg='purple',和tk.Label(window, text='错误,Windows正遭受蔡徐坤和鸡你太美攻击!', bg='red'里,颜色以可以改。
效果: