私はウィンドウを持っていて、イメージを追加しようとしています。ここまでのウィンドウは、ラベル入力ボックスとボタンで構成されています。私はラベルの下にあるが、入力ボックスのボタンの上に画像を追加したい。ここに私のコードは次のとおりです。tinkter pythonウィンドウにpng画像を追加するには?
master = Tk()
master.wm_title("Lightning Parties")
master.configure(background='lightgreen')
Label(master, text="Staff Login", fg='black', bg='lightgreen', font= ('comicsans', 14)).grid()
Label(master, text="Please enter the password ", fg='black', bg='lightgreen', font=('comicsans', 12)).grid(row=7)
Password= Entry(master)
Password.grid(row=7, column=1)
Button(master, text='Login', command=validateStaff, fg='black', bg='white', font=('comicsans', 12)).grid(row=10, column=1, sticky=W, pady=4)
私は追加する画像は、ファイル名「sonic.png」を有します。
利用可能なドキュメントを読むことで解決できない問題はありますか? tkinterプログラムに画像を追加する方法を示すインターネット上の例があります。 –
@BryanOakleyが正しく述べたように、SOに投稿する前に一度デバッグしてください。これらの記事を見ていると言います。 1. [tkinter-photoimage-doesnt-not-support-png-image](0120-18753-1)/ tkinter-photoimage-doesnt-not-support-png-image.jpg 2。 [How-to-add-an-image-in-tkinter-python-2-7](http://stackoverflow.com/questions/10133856/how-to-add-an-image-in-tkinter-python- 2-7) –
チュートリアルまたはドキュメントを読む:ie。 [Tkinter PhotoImageクラス](http://effbot.org/tkinterbook/photoimage.htm) – furas