tkinter图像查看器

tkinter图像查看器

李兴球Python简易图像查看器tkinter


单击按钮,选择图像,就会显示图像。使用了文件对话框中的askopenfilename命令。

"""
图像查看器.py,不支持查看gif动图版
"""
from tkinter import *
from tkinter import filedialog

def _blankimage():
"""返回空白图形对象
"""
img = PhotoImage(width=1, height=1)
img.blank()
return img

def openimage():
global pmg
f = filedialog.askopenfilename(title='打开图像',
filetypes=[("PNG图像",".png"), ("JPG图像",".jpg"), ("GIF图像",".gif")])
pmg = PhotoImage(file=f)

cv.config(width=pmg.width(),height=pmg.height())
cv.itemconfig(pic,image=pmg)
return f

成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

李兴球

李兴球的博客是Python创意编程原创博客