1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python实现动态壁纸_ubuntu下用python写了个生成动态壁纸的脚本 如果通过代码实现使

python实现动态壁纸_ubuntu下用python写了个生成动态壁纸的脚本 如果通过代码实现使

时间:2018-08-02 03:50:47

相关推荐

python实现动态壁纸_ubuntu下用python写了个生成动态壁纸的脚本 如果通过代码实现使

社区助手xx

-03-03 09:23:23

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('\n')

f.write('\t\n')

f.write('\t\t' + str(currentTime.tm_year) + '\n')

f.write('\t\t' + str(currentTime.tm_mon) + '\n')

f.write('\t\t' + str(currentTime.tm_mday) + '\n')

f.write('\t\t' + str(currentTime.tm_hour) + '\n')

f.write('\t\t' + str(currentTime.tm_min) + '\n')

f.write('\t\t' + str(currentTime.tm_sec) + '\n')

f.write('\t\n')

f.write('\n')

for i in currentImageFiles:

length = length - 1

f.write('\t\n')

f.write('\t\t550.0\n')

f.write('\t\t' + currentImageFiles[length] +'\n')

f.write('\t\n')

f.write('\t\n')

f.write('\t\t25.0\n')

f.write('\t\t' + currentImageFiles[length] + '\n')

if length >= 1:

f.write('\t\t' + currentImageFiles[length-1] + '\n')

if length <1:

f.write('\t\t' + currentImageFiles[len(currentImageFiles)-1] + '\n')

f.write('\t\n')

f.write('\n')

f.close()

python实现动态壁纸_ubuntu下用python写了个生成动态壁纸的脚本 如果通过代码实现使用这个xml 而不是通过桌面...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。