[Python Wpg] Gnome background switcher!!!
Stuart Williams
stuartw at mts.net
Mon Jun 5 23:33:11 EDT 2006
>>>>> Scott Balneaves writes:
> Subject: [Python Wpg] Gnome background switcher!!!
Cool!
A couple of alternatives occurred to me.
First, there's an os.walk function which you could use like this, also
switching the filelist to a value returned from walk_tree.
...
def walk_tree(d):
result = []
for root, dirs, files in os.walk(d):
result.extend([os.path.join(root, f) for f in files])
return result
...
filelist = walk_tree(options.folder)
...
Also the itertools.cycle function can simplify the switching code
thusly:
...
self.filelist = cycle(filelist)
# self.filelistlen = len(self.filelist)
def change_background(self):
"""
Change the gconf background key to the next image file in the list.
"""
self.ready.acquire ()
self.client.set_string('/desktop/gnome/background/picture_filename',
self.filelist.next())
self.ready.release()
return 1
By the way, is the thread.Threading.Condition lock (acquire/release)
necessary?
Stuart.
More information about the Winnipeg
mailing list