Python编程:制作电子相册
来源:互联网 发布:朋友圈访客记录软件 编辑:程序博客网 时间:2024/04/30 15:11
Python编程:制作电子相册
本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明.
环境:
主机:WIN10
python版本:3.5
开发环境:pyCharm 5.0.2
说明:
家里有不用的windows平板me400c,用python编写一个脚本,实现电子相册功能。
功能:
1.每5s自动播放下一张
2.可以手动点击,播放下一张
效果:
源代码:
import osimport threadingimport tkinter as tkimport timefrom PIL import ImageTk, Image#分辨率resolution = (1366, 768)# 路径Path = 'd:\photo'# 播放间隔.单位:sInterval = 5# 当前照片计数Index = 0scaler = Image.ANTIALIASroot = tk.Tk()img_in = Image.open("load.jpg")w, h = img_in.sizesize_new = ((int)(w * resolution[1] / h), resolution[1])img_out = img_in.resize(size_new, scaler)img = ImageTk.PhotoImage(img_out)# img = ImageTk.PhotoImage(Image.open("load.jpg"))panel = tk.Label(root, image = img)panel.pack(side = "bottom", fill = "both", expand = "yes")def callback(e): global Index files = os.listdir(Path) i = 0 for x in files: # 判断文件是否存在 if not os.path.isfile(Path + '\%s' % x): break if i < Index: i += 1 continue print('手动处理图片', x, Index) if not (x.endswith('.jpg') or x.endswith('.JPG')): i += 1 Index += 1 if Index >= len(files): Index = 0 continue img_in = Image.open(Path + '\%s' % x) print(img_in) w, h = img_in.size size_new = ((int)(w * resolution[1] / h), resolution[1]) img_out = img_in.resize(size_new, scaler) img2 = ImageTk.PhotoImage(img_out) # img2 = ImageTk.PhotoImage(Image.open(Path + '\%s' % x)) panel.configure(image=img2) panel.image = img2 Index += 1 if Index >= len(files): Index = 0 break# root.bind("<Return>", callback)root.bind("<Button-1>", callback)def image_change(): global Index time.sleep(3) while True: files = os.listdir(Path) i = 0 for x in files: # 判断文件是否存在 if not os.path.isfile(Path + '\%s' % x): break if i < Index: i += 1 continue print('自动处理图片', x, Index) if not (x.endswith('.jpg') or x.endswith('.JPG')): i += 1 Index += 1 if Index >= len(files): Index = 0 continue img_in = Image.open(Path + '\%s' % x) w, h = img_in.size size_new = ((int)(w * resolution[1] / h), resolution[1]) img_out = img_in.resize(size_new, scaler) img2 = ImageTk.PhotoImage(img_out) # img2 = ImageTk.PhotoImage(Image.open(Path + '\%s' % x)) panel.configure(image=img2) panel.image = img2 Index += 1 if Index >= len(files): Index = 0 time.sleep(Interval)# 图片切换线程t = threading.Thread(target=image_change)t.start()root.mainloop()
0 0
- Python编程:制作电子相册
- 制作电子相册
- 制作电子相册
- 电子相册的制作代码
- 电子相册制作软件评测排名
- 用会声会影10制作高保真电子相册
- flash+xml 制作电子相册教程
- 用ASP制作一个电子相册,
- 会声会影如何制作简易电子相册
- 用《会声会影》快速制作VCD电子相册
- 电子相册制作工具memoriesontv4使用教程
- 简单练手 使用css样式制作电子相册
- 电子相册制作软件,还是使用 数码大师
- Android端立体电子相册的制作
- 用PPT制作精美的专业电子相册
- python 编程(制作python库)
- 简单电子相册视频制作的步骤和要点
- 影集电子相册制作系统普及版 39.9.7已注册版
- erlang环境搭建
- 欢迎使用CSDN-markdown编辑器
- 文件操作
- 三层的构建
- .net附件接口实现
- Python编程:制作电子相册
- fastDFS介绍和安装
- Oracle数据库错误记录
- Java泛型详解
- fastDFS存储视频和文件
- POJ2217——Secretary(后缀数组应用)
- 【poj1201】【poj2983】【差分约束系统】
- Http Post 和 Get的请求区别
- 洛谷 P1052 [NOIP2005 T2] 过河