from PIL import Image
import time
from PIL import Image, ImageDraw, ImageFont
import win32api, win32gui, win32con
def setWallPaper(pic):
# open register
regKey = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\Desktop",0,win32con.KEY_SET_VALUE)
win32api.RegSetValueEx(regKey,"WallpaperStyle", 0, win32con.REG_SZ, "2")
win32api.RegSetValueEx(regKey, "TileWallpaper", 0, win32con.REG_SZ, "0")
# refresh screen
win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER,pic, win32con.SPIF_SENDWININICHANGE)
taskfile=open("C:\tmp\task.txt");
txt = Image.new('RGBA', (1920,1080), (0,0,0,0))
# get a font
# get a drawing context
d = ImageDraw.Draw(txt)
# draw text, half opacity
font = ImageFont.truetype("simhei.ttf", 40, encoding="utf-8")
d.text((1300,10), time.strftime("%Y-%m-%d"),font=font,fill=(255,255,255,128))
d.text((1300,60), taskfile.read(),font=font,fill=(255,255,255,128))
taskfile.close();
# draw text, full opacity
txt.save('C:\tmp\boot0.bmp')
txt.show()
txt.close()
setWallPaper('C:\tmp\boot0.bmp')
# get an image