Saturday, 14 November 2009

Working on the random image change idea I have managed to display a diffrent image each time the app is started. this is the code i used:

import os
import random
import shutil
import glob

glob.glob('*.png')
List = []

def imageupdate():
for root, dirs, files in os.walk('Downloads/'):
for name in files:
filename = os.path.join(root, name)
List.extend([filename])
rand = random.choice(List)
shutil.copy2(rand, 'temp.png')

The bigest problem i can see with this is that as the downloads folder fills up the app will take longer to start.
Im thinking that i should put a size limit on the list

No comments:

Post a Comment