【发布时间】:2017-11-26 17:36:19
【问题描述】:
我最近切换到 Python 2.7(从 3.4),但在读取带有 Tkinter Photoimage 类的 .png 文件时遇到问题。我说:
background = "background.png"
photo = tk.PhotoImage(file=background)
但我收到此错误:
Traceback (most recent call last):
File "main.py", line 36, in <module>
photo = tk.PhotoImage(file=background)
File "c:\Python27\lib\lib-tk\Tkinter.py", line 3323, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "c:\Python27\lib\lib-tk\Tkinter.py", line 3279, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "background.png"
【问题讨论】:
标签: tkinter