您好我想在这里加载几个框架对象:Matwin 用我的对象的数据:材料 我试图在这里添加材料作为我的Matwin对象的参数,但是它不起作用......
这里有我的代码:
class Matwin(PanedWindow):
def __init__(self,parent,mat):
PanedWindow.__init__(self,parent,mat)
self.pack()
self.parent= parent
self.bouton=Button(self, text=mat.path, padx=10,pady=10,command=mat.command)
self.bouton.pack()
self.label = Label(self, text=mat.nom)
self.label.pack()
class Material:
def __init__(self,name):
self.name = name
self.path = "Picture path"
def command(self):
print("this is the ",self.name," command")
win = Tk()
aobj = Material("a")
bobj = Material("b")
cobj = Material("c")
listobj =[aobj,bobj,cobj]
i = 0
while i < len(listobj):
test = Matwin(win,listobj[i])
我有TypeError:类型&#39;材料&#39;是不可迭代的 也许这不是一个好方法,你可以帮助我吗?