简体   繁体   English

.png 是 python 的 tkinter 模块中唯一可接受的格式吗?

[英]Is .png the only format acceptable in python's tkinter module?

I tried inserting a picture with format.jpg as a PhotoImage我尝试将带有 format.jpg 的图片作为 PhotoImage 插入

But everytime i try running the program, it gives the following error:但是每次我尝试运行程序时,都会出现以下错误:

couldn't recognize data in image file无法识别图像文件中的数据

But this never happens with an.png picture, which makes me wonder if.png is the only format acceptable in tkinter?但这绝不会发生在 .png 图片上,这让我想知道 .png 是否是 tkinter 中唯一可接受的格式?

The docstring for PhotoImage says : PhotoImage的文档字符串说

class PhotoImage(Image):
    """Widget which can display images in PGM, PPM, GIF, PNG format."""

So no, PNG is not the only acceptable format.所以不,PNG 不是唯一可接受的格式。 PGM, PPM, GIF, and PNG are. PGM、PPM、GIF 和 PNG 是。 JPEG is not. JPEG 不是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM