AttributeError:' NoneType'对象没有属性' pack'

时间:2013-04-24 03:47:54

标签: python tkinter pygame

我正在使用此代码:

if imgAct < len(limg):
    img = ImageTk.PhotoImage(Image.open(path+limg[imgAct]))
    f=etiq.config(image = img)
    f.pack(side = "bottom", fill = "both", expand = "yes")
    f.pack(side = "bottom", fill = "both", expand = "yes")

但是我收到了这个错误:

  

AttributeError NoneType对象没有属性pack

如何解决此错误?

1 个答案:

答案 0 :(得分:6)

呼叫中

f被设置为None

f = etiq.config (image = img)

这就是造成错误的原因:

AttributeError: 'NoneType' object has no attribute 'pack'

当您执行f.pack()

您需要将None返回值排序。有了这个特殊的方面,我无法帮助,因为etiq的粗略谷歌出现了"For women who want to be empowered with credible facts about estrogen therapy",我很确定这与您正在使用的库无关: - )