Tkinter.PhotoImage doesn't not support png image

前端 未结 6 862
礼貌的吻别
礼貌的吻别 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 08:59

    Fixed in official python.org 64-bit (only) installer for OS X. Tk version 8.6 is included out of the box. Warning: if you use homebrew, as of this post doing brew install python3 will only give you 8.5, and 8.6 is required to use png so you'll have to use official installer instead. To check which Tk you are using:

    $ python3 -c 'import tkinter; print(tkinter.TkVersion);'
    

    If it report 8.6, you are good to go.

提交回复
热议问题