ubuntu 下用python写了个生成动态壁纸的脚本,如果通过代码实现使用这个xml,而不是通过桌面->背景->添加 想在ubuntu下写Python程序,应该使用什么软件?不想...

python \u53ef\u4ee5\u5199 \u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u4e0d\uff1f\u9700\u8981\u4f9d\u8d56 python \u4e48\uff1fpython \u662f\u4e0d\u662f \u7c7b\u4f3c.net framework?

Python\u53ef\u4ee5\u5199\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\uff0c\u5927\u540d\u9f0e\u9f0e\u7684wxPython\u5c31\u662f\u505a\u8fd9\u4e2a\u7684\uff0c\u53ef\u7528\u7684\u63a7\u4ef6\u975e\u5e38\u591a\u3002\u7528Python\u5199\u7684\u7a0b\u5e8f\uff0c\u8981\u88c5\u4e86Python\u624d\u80fd\u8fd0\u884c\uff0c\u9664\u975e\u4f60\u628a\u5b83\u7f16\u8bd1\u6210exe\uff0c\u4e0d\u8fc7\u76ee\u524d\u8fd9\u9879\u6280\u672f\u8fd8\u4e0d\u6210\u719f\u3002

\u4f60\u53ef\u4ee5\u73b0\u5728\u6587\u672c\u7f16\u8f91\u5668\u91cc\u5199\u597d\u4ee3\u7801\uff0c\u547d\u540d\u4e3a.py\u6587\u4ef6\uff0c\u518d\u5728\u7ec8\u7aef\u91cc\u6267\u884c\u5b83\u3002

sudo mkdir /usr/share/backgrounds/mybackground-imgs
sudo cd /usr/share/backgrounds/mybackground-imgs
sudo cp /home/你的背景图片所在目录/* .
sudo ./backgroud.py

其中backgroud.py:
#!/usr/bin/env python
#coding=utf-8
import glob, os
import shutil
import time
import Image

filelist=[]
def filelie(path):
if os.path.isfile(path):
wenjian=os.path.splitext(path)[1][1:]
if wenjian=="jpg" or wenjian=="png" or wenjian=="gif":
try:
kuan,gao = Image.open(path).size
if kuan>=1024 and gao>=768:
filelist.append(path)
except IOError:
pass
elif os.path.isdir(path):
for item in os.listdir(path):
itemsrc = os.path.join(path, item)
filelie(itemsrc)

curdir = os.getcwd()
filelie(curdir)
currentImageFiles = filelist
#print filelist
if os.path.isfile('backgroundslide.xml'):
os.remove('backgroundslide.xml')

currentTime = time.localtime()
length = len(currentImageFiles)

f = file('backgroundslide.xml', 'w')

f.write('<background>\n')
f.write('\t<starttime>\n')
f.write('\t\t<year>' + str(currentTime.tm_year) + '</year>\n')
f.write('\t\t<month>' + str(currentTime.tm_mon) + '</month>\n')
f.write('\t\t<day>' + str(currentTime.tm_mday) + '</day>\n')
f.write('\t\t<hour>' + str(currentTime.tm_hour) + '</hour>\n')
f.write('\t\t<minute>' + str(currentTime.tm_min) + '</minute>\n')
f.write('\t\t<second>' + str(currentTime.tm_sec) + '</second>\n')
f.write('\t</starttime>\n')
f.write('<!--This animation will start at the time it created-->\n')

for i in currentImageFiles:
length = length - 1
f.write('\t<static>\n')
f.write('\t\t<duration>550.0</duration>\n')
f.write('\t\t<file>' + currentImageFiles[length] +'</file>\n')
f.write('\t</static>\n')
f.write('\t<transition>\n')
f.write('\t\t<duration>25.0</duration>\n')
f.write('\t\t<from>' + currentImageFiles[length] + '</from>\n')
if length >= 1:
f.write('\t\t<to>' + currentImageFiles[length-1] + '</to>\n')
if length <1:
f.write('\t\t<to>' + currentImageFiles[len(currentImageFiles)-1] + '</to>\n')
f.write('\t</transition>\n')

f.write('</background>\n')
f.close()

好像是需要配置gconf,看看有没有可以配置gconf的python库吧.
gconf就像是gnome下的注册表.

将xml文件拷贝到 /usr/share/backgrounds/cosmos/

扩展阅读:java windowbuilder ... ubuntu nomodeset ... plymouth boot screen ... powerautomate ... ubuntu官网网址 ... ubuntu tracepath ... ubuntu touch anbox ... vmware localhost login ... ubuntu touch docker ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网