open_image_dialog.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:mountain_tapir 作者: tttppp 项目源码 文件源码
def setThumbnail(self, imageButtonPair):
            """Try to load the image from the path and display it on the button.

            :param imageButtonPair: A pair containing an image path and a button."""
            button = imageButtonPair[1]
            if not button.winfo_exists():
                # This might happen if the refresh button has been pressed, or navigation has taken place.
                return
            imagePath = imageButtonPair[0]
            if imagePath not in OpenImageDialog.thumbnailCache.keys():
                imageFile = ImageFile(imagePath)
                image = imageFile.getImageObject((64, 50), 'openDialog')
                OpenImageDialog.thumbnailCache[imagePath] = image
            image = OpenImageDialog.thumbnailCache[imagePath]
            if image is not None:
                button.image = ImageTk.PhotoImage(image)
                try:
                    button.config(image=button.image)
                except TK.TclError:
                    # This might happen if the dialog has been closed.
                    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号