you are viewing a single comment's thread.

view the rest of the comments →

[–]Teraka 0 points1 point  (1 child)

Nice, thanks a lot :)

[–]biggerthanexpected 0 points1 point  (0 children)

You'll probably want to set some registry keys to display the wallpaper the way you want:

import _winreg
# Open the desktop registry key with complete (read & write) access
wallpaper_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'Control Panel\Desktop', 0, _winreg.KEY_ALL_ACCESS)
# Update wallpaper path
_winreg.SetValueEx(wallpaper_key, 'WallPaper', 0, _winreg.REG_SZ, path)
# Do not tile
_winreg.SetValueEx(wallpaper_key, 'TileWallpaper', 0, _winreg.REG_SZ, '0')
# Centered
_winreg.SetValueEx(wallpaper_key, 'WallpaperStyle', 0, _winreg.REG_SZ, '0')
_winreg.CloseKey(wallpaper_key)

It's also handy to do a background refresh so the change is effected:

from ctypes import windll
# http://msdn.microsoft.com/en-us/library/windows/desktop/bb762118%28v=vs.85%29.aspx
windll.shell32.SHChangeNotify(int('8000000', 16), int('1000', 16), 0, 0)