Tkinter.PhotoImage doesn't not support png image

前端 未结 6 832
礼貌的吻别
礼貌的吻别 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:06

    Tkinter 8.6 supports png file format while tkinter 8.5 does not. If you have the option upgrade python and you should be fine to use png. If you have to use an older version of python you should use Pillow (maintained pil fork) which also works on python3.

    If you are starting a new project do not use python2 or PIL as suggested in the accepted answer, they are both depreciated technologies.

提交回复
热议问题