Pythonでつくる ゲーム開発 入門講座でプログラミングを勉強しているものです。
写真と同じ様に打ち込んでいてウィンドウは指示通り表示されますが、画像だけ表示されません。
公式サイトからデータはダウンロードした後に解凍もした為、何に問題があるのか自分では発見出来ないため、わかる方アドバイスお願いします
MacBook Airです
import tkinter
root = tkinter.Tk()
root.title("初めての画像表示")
canvas = tkinter.Canvas(root, width=400, height=600)
canvas.pack()
gazou = tkinter.PhotoImage(file="iroha.png")
canvas.create_image(200, 300, image=gazou)
root.mainloop()
以下エラーメッセージです。
Traceback (most recent call last):
File "/Users/mon/Desktop/python_game/list0604_2.py", line 6, in <module>
gazou = tkinter.PhotoImage(file="iroha.png")
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/init.py", line 4061, in init
Image.init(self, 'photo', name, cnf, master, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/init.py", line 4006, in init
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "iroha.png": no such file or directory
あなたの回答
tips
プレビュー