The following bit of python code is supposed to download an BMP image from the web and save it to disk, then change the wallpaper to the downloaded image. The wallpaper change is supposed to be permanent ie not revert back after restart. This function is part of a larger script that I am compiling into a binary exe using pyinstaller. The problem is that when I run the program the bit that is supposed to change the wallpaper is not working and I am at wits end trying to figure out why. The funny thing is if I run this exact code in the python interpreter it works as expected. Also, in a previous version of the compiled script, the wallpaper change worked without a hitch. Any comments, help, insights would be greatly appreciated!
def wallpaper():
try:
os.chdir(launch_directory)
urllib.urlretrieve('http://www.imagehost.com/image.bmp', 'image.bmp')
ctypes.windll.user32.SystemParametersInfoA(20, 0, os.path.join(launch_directory, "image.bmp"), 1)
except:
pass