单击按钮,选择图像,就会显示图像。使用了文件对话框中的askopenfilename命令。
"""
图像查看器.py,不支持查看gif动图版
"""
from tkinter import *
from tkinter import filedialogdef _blankimage():
"""返回空白图形对象
"""
img = PhotoImage(width=1, height=1)
img.blank()
return imgdef 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资源。)
发表评论