The library have a bug. To overcome follow these steps.
1. Open wallpaper library directory and create a file name win-wallpaper.py.
2. Add following code into newly create module .
import ctypes,win32con
def getWallpaper():
ubuf = ctypes.create_unicode_buffer(512)
ctypes.windll.user32.SystemParametersInfoW(win32con.SPI_GETDESKWALLPAPER,len(ubuf),ubuf,0)
return ubuf.value
print(getWallpaper())
3. Then use pyinstaller to convert py to exe file.
Note: Don't use cmd for compile purpose .
pyinstaller --onefile -w 'win-wallpaper.py'
4. From dist folder take win-wallpaper.exe file to main directory.
Now, it is good to go.
But one thing you should not here, this library still not contain proper implementation of set_wallpaper(path) function. This contain lots of bug so please use last code stuff.
If you don't want to use this library then use this code.
import ctypes,win32con
def getWallpaper():
ubuf = ctypes.create_unicode_buffer(512)
ctypes.windll.user32.SystemParametersInfoW(win32con.SPI_GETDESKWALLPAPER,len(ubuf),ubuf,0)
return ubuf.value
def setWallpaper(path):
changed = win32con.SPIF_UPDATEINIFILE | win32con.SPIF_SENDCHANGE
ctypes.windll.user32.SystemParametersInfoW(win32con.SPI_SETDESKWALLPAPER,0,path,changed)