1
嗨,我想把圖像作爲我的按鈕之一的背景,我已經在我的主窗口中的很多其他按鈕上做了這個,但這個特定的按鈕坐在頂級窗口內,圖像不會像它應該加載,有沒有人知道爲什麼? (我也曾嘗試定義按鈕的寬度和高度,但仍然不顯示圖像)tkinter按鈕不顯示圖像
def rec_window():
recw = Toplevel(width=500,height=500)
recw.title('Record To.....')
img1 = PhotoImage(file="C:/Users/Josh Bailey/Desktop/pi_dmx/Gif/mainmenu.gif")
Button(recw, image=img1, command=rec_preset_1).grid(row=1, column=1)
Button(recw, text="Preset 2", bg = 'grey70',width=40, height=12,command=rec_preset_2).grid(row=1, column=2)
Button(recw, text="Preset 3", bg = 'grey70',width=40, height=12,command=rec_preset_3).grid(row=2, column=1)
Button(recw, text="Preset 4", bg = 'grey70',width=40, height=12,command=rec_preset_4).grid(row=2, column=2)
Button(recw, text="Cancel", bg='grey70', width=20, height=6, command=recw.destroy). grid(row=3,column=1,columnspan=2, pady=30)
有這個(這裏)沒有(http://www.tkdocs.com /tutorial/widgets.html)或[這裏](http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Button.html),這正是爲什麼一個圖標沒有出現在我的應用程序中的一個按鈕 - 非常感謝。 –