Tkinter.PhotoImage doesn't not support png image

前端 未结 6 864
礼貌的吻别
礼貌的吻别 2020-11-27 08:51

I am using Tkinter to write a GUI and want to display a png file in a Tkiner.Label. So I have some code like this:

self.vcode.img = PhotoImage(d         


        
6条回答
  •  半阙折子戏
    2020-11-27 09:12

    tkinter only supports 3 file formats off the bat which are GIF, PGM, and PPM. You will either need to convert the files to .GIF then load them (Far easier, but as jonrsharpe said, nothing will work without converting the file first) or you can port your program to Python 2.7 and use the Python Imaging Library (PIL) and its tkinter extensions to use a PNG image.

    A link that you might find useful: http://effbot.org/tkinterbook/photoimage.htm

提交回复
热议问题