您无法使用tkinter加载 .png
格式。您需要为此使用PIL库:
import PILimage = PIL.Image.open("bitcoin.png")BTC_img = PIL.ImageTk.PhotoImage(image)BTC_img_label = tk.Label(self, image=BTC_img)BTC_img_label.image = BTC_imgBTC_img_label.grid(row=2, column=0)编辑:
请创建一个
test.py文件并运行以下确切代码:
import tkinter as tkfrom PIL import Image, ImageTkroot = tk.Tk() image = Image.open("bitcoin.png")photo = ImageTk.PhotoImage(image)label = tk.Label(root, image=photo)label.image = photolabel.grid(row=2, column=0)#Start the programroot.mainloop()告诉我您是否遇到错误。



