开发者

Changing wallpapers in python

I'm running a Maverick on my machine, and I'm trying to write a script to change wallpapers in python. Heres my progress so far.

import gconf
client = gconf.client_get_default()
current_bg = client.get_string("/desk开发者_Python百科top/gnome/background/picture_filename")
client.set_string("/desktop/gnome/background/picture_filename","home/tsudot/Pictures/zombie.jpg")

After running the script I get a blank wallpaper. It shows me a white screen.

I examined the gcnonf.xml file and the change has been made there.

Can anybody help me out?


The problem is probably that you're missing a / at the beginning of home/tsudot/Pictures/zombie.jpg so the file isn't found. To avoid this problem happening in the future, you could perhaps change your code to keep the filename in a variable and check before trying to set the config option that that file exists with os.path.exists(filename).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜