尝试使用标签在tkinter上上传图像时出现错误

时间:2019-10-08 15:27:02

标签: python tkinter

当我尝试使用tkinter上传图像时出现错误 我已经下载了一张gif图片,并将其保存在名为“ image.gif”的文件中,并将图片另存为“ image”

#Add a picture using label

logo = PhotoImage(file="img.gif")

w1 = Label(news_window, image=logo).pack(side="right")

w2 = Label(news_window, 
              justify=RIGHT,
              padx = 10, 
              text=explanation).pack(side="right")

我收到的错误消息是“权限被拒绝”

1 个答案:

答案 0 :(得分:0)

  

您忘记声明root-root = Tk()。使用Tk系统之前,必须先将其打开。

Python Tkinter Error, "Too Early to Create Image"