tl;dr The usual way of using python to set the desktop background using ctypes is too slow for animation purposes. I'm wondering if I have any options to set the background at O(5fps) without destroying my computer's performance.
~~~~
Howdy folks!
The other day I got excited about this idea I had: I wanted to make my desktop background cycle through the most recent images of the Sun (from SDO), as downloaded from a NASA website. And it worked! I have a code that runs in the background on my computer, and updates my desktop every thirty seconds to the newest image from the internet (it also cycles through the wavelengths. Very fun!.) And it is really cool! Looking at it every day and seeing how the sun changes is cool. So that's a success.
But the Sun also has a lot of short term dynamics that I'd like to be able to observe as well! So, I thought, the solution is easy enough! Just keep the last 30 images you downloaded and serve them up rapid fire! The loop is easy enough (distilled to the base components):
import os
import ctypes
import time
#Get the filepaths of all pictures in a folder
folderPath = fromGod()
items = os.listdir(folderPath)
listOfFiles = [folderPath + item for item in items]
frameTime = 0.25 #second
runFor = 30 #seconds
#Cycle through the pictures
startTime = time.time()
while time.time() - startTime < runFor:
for file in listOfFiles:
ctypes.windll.user32.SystemParametersInfoW(20, 0, file , 0)
time.sleep(frameTime)
This actually does work! It looks pretty nice, and I would even settle for the 4 fps it seems capable of before it just stops working at all. The problem is that every call to the ctypes function causes the whole system to {freeze?. stutter?, slow down?}. It totally kills the idea, because there is no way I can let this code run in the background. It makes my mouse stutter across my screen.
But I see that programs exist that can make the desktop background be a movie, so I'm hoping there is some other way I can do this on my own in python. I guess I just don't understand why this function should have such a drain on the system. But searching here on stack overflow and on google has not been fruitful in terms of alternate ways to do this.
I am on a Dell Windows 10 laptop, running python 3.6.5 in Anaconda form.