_tkinter.TclError: couldn't recognize data in image file "./chap3-back.png"とエラーが出ました。
game_python フォルダをアプリの名前として、
chap3.pyとchap3-back.png をそのフォルダの中に入れました。
import tkinter img = tkinter.PhotoImage(file="./chap3-back.png")
とコードを書いて実行すると
Traceback (most recent call last): File "chap3.py", line 9, in <module> img = tkinter.PhotoImage(file="./chap3-back.png") File "/Users/XXX/anaconda/envs/py36/lib/python3.6/tkinter/__init__.py", line 3539, in __init__ Image.__init__(self, 'photo', name, cnf, master, **kw) File "/Users/XXX/anaconda/envs/py36/lib/python3.6/tkinter/__init__.py", line 3495, in __init__ self.tk.call(('image', 'create', imgtype, name,) + options) _tkinter.TclError: couldn't recognize data in image file "./chap3-back.png"
とエラーが出ました。
img = tkinter.PhotoImage(file="chap3-back.png")
と書いて実行もしたのですが同じエラーが出ました。
ディレクトリが間違っているわけはないのですが...。
tkinterを使うときはディレクトリ指定の方法が変わるのでしょうか?

回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。