代码拉取完成,页面将自动刷新
import tkinter
import tkinter.messagebox
import time
import os
from PIL import Image, ImageGrab, ImageFilter
gif_path = './static/screen.gif'
blur_path = './static/blur.gif'
gap = 1
rest_time = 300
work_time = 2400
def showwarning():
rest_msg = "该休息一下了"
top.withdraw()
tkinter.messagebox.showwarning(message=rest_msg)
def sleep(t):
time.sleep(t)
def auto_close():
sleep(2)
top.destroy()
def safe_check():
if not os.path.exists(gif_path):
b = os.getcwd()
os.mkdir(b+"\\static")
while True:
sleep(work_time)
top = tkinter.Tk()
top.attributes("-topmost", 1)
sleep(gap)
showwarning()
sleep(gap)
w = top.winfo_screenwidth()
h = top.winfo_screenheight()
bbox = (0, 0, w, h)
screen = ImageGrab.grab(bbox)
safe_check()
screen.save(gif_path)
screen = Image.open(gif_path)
screen = screen.convert('RGB').filter(ImageFilter.BLUR)
screen.save(blur_path)
screen.close()
img = tkinter.PhotoImage(file=blur_path)
imgLabel = tkinter.Label(top, image=img)
imgLabel.pack()
top.attributes("-fullscreen", True)
top.wm_deiconify()
top.after(rest_time * 1000, top.destroy)
top.mainloop()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。