Python AttributeError:“super”对象在尝试将小部件添加到版面的个性化id时没有属性“\uuuu getattr\uuuuuuu”

Python AttributeError:“super”对象在尝试将小部件添加到版面的个性化id时没有属性“\uuuu getattr\uuuuuuu”,python,kivy,Python,Kivy,当尝试将问题中的布局添加到我修改为布局的个性化id时,它会启动一个错误,我认为我没有识别个性化id gr_ly = GridLayout(id=i[1], rows=1) self.LayoutGeneralCI.ids.realll.add_widget(gr_ly) #Adding another widget to the custom id layout but just always puts me the widgets into the last layout executed

当尝试将问题中的布局添加到我修改为布局的个性化id时,它会启动一个错误,我认为我没有识别个性化id

gr_ly = GridLayout(id=i[1], rows=1)

self.LayoutGeneralCI.ids.realll.add_widget(gr_ly)

#Adding another widget to the custom id layout but just always puts me the widgets into the last layout executed

gr_ly.add_widget(self.DatosLayoutCI)
这里有所有的代码

def selection_data_secciones(self):

    self.mainwid.dataBase = sqlite3.connect("UserData")
    self.mainwid.dataCursor = self.mainwid.dataBase.cursor()
    self.mainwid.dataCursor.execute("SELECT * FROM SECCIONES")
    fetch = self.mainwid.dataCursor.fetchall()
    for i in fetch:
        self.LayoutGeneralCI = LayoutGeneralCI(self.mainwid)  
        ref_idd = i[1]
        gr_ly = GridLayout(id=i[1], rows=1)
        print(type(gr_ly.id))
        self.LayoutGeneralCI.ids.realll.add_widget(gr_ly)
        print(self.LayoutGeneralCI.ids)
        self.LayoutGeneralCI.ids.title_sect_lbl.text = i[1]
        self.ids.container_ci.add_widget(self.LayoutGeneralCI) 
    for produ in self.mainwid.dataCursor.execute("SELECT * FROM MATERIALES"):
        self.DatosLayoutCI = DatosLayoutCI(self.mainwid)
        txtvar_ci = "Nombre: [b]{}[/b] \n".format(produ[1])
        txtvar2_ci = "Proveedor: [b]{}[/b] \n".format(produ[3])
        if produ[8] <= str(0):
            txtvar3_ci = "Disponibilidad: [color=#FF0000][b]Agotado[/b][/color]" 
        else:
            txtvar3_ci = "Disponibilidad: [color=#00FF00][b]Disponible[/b][/color]"
        txtvargeneral_ci = txtvar_ci + txtvar2_ci + txtvar3_ci
        self.DatosLayoutCI.ids.content_cill.text = txtvargeneral_ci
        var_sectttion = self.mainwid.AgregarProductos.ids.section_product.text#
        var_reference_id = produ[2]  
        gr_ly.add_widget(self.DatosLayoutCI)
    self.mainwid.dataBase.commit()   #DISCOMMENT NECCESARY
    self.mainwid.dataBase.close()
问题2 一直在向最后一个小部件添加DatosLayoutCI小部件

解决方案 为了显示每个小节项下的所有材质,必须使用一个带有内部联接的SQL语句或两个嵌套SELECT的SELECT语句

片段-嵌套选择 问题1 原因 在Python脚本中创建的ID与在kv文件中创建的ID不同

Kivy文档 分歧 kv文件 为id赋值时,请记住该值不是字符串。没有引号:good->id:value,bad->id:'value' 使用self.ids.reall或self.ids['reall']在Python脚本中访问它 解析kv文件时,kivy收集所有标记有id的小部件,并将它们放在self.ids字典类型属性中。这意味着您还可以迭代这些小部件并以字典的方式访问它们。 py文件 id是一个字符串 无法使用self.ids.var访问它 未存储在self.id中 解决方案
我尝试了这个解决方案,但结果是一样的,具体的问题是我想添加到与布局id相同的个性化布局小部件中,但在运行时尝试此代码总是在最终执行的布局上插入布局,另一个建议,请帮助如果您要添加两个gr_ly,那么您必须在实例化每个gr_ly后执行gr_ly.add_widgetself.DatosLayoutCI。为了更好地理解问题,我添加了更多代码,请检查一下,希望您能找到答案!,谢谢,我需要一个答案!你太棒了!!您必须在这个问题中添加更多代码,另一个问题将在将来自动删除,以便将来的读者不会理解您的问题,其想法是,您的问题将不仅服务于您,而且服务于现在和将来的社区
self.LayoutGeneralCI.ids.var.add_widget(self.DatosLayoutCI)
File "kivy\properties.pyx", line 841, in kivy.properties.ObservableDict.__getattr__
 AttributeError: 'super' object has no attribute '__getattr__'
def selection_data_secciones(self):

    self.mainwid.dataBase = sqlite3.connect("UserData")
    self.mainwid.dataCursor = self.mainwid.dataBase.cursor()
    self.mainwid.dataCursor.execute("SELECT * FROM SECCIONES")  # Sections
    fetch = self.mainwid.dataCursor.fetchall()

    for i in fetch:
        self.LayoutGeneralCI = LayoutGeneralCI(self.mainwid)
        ref_idd = i[1]
        gr_ly = GridLayout(id=i[1], rows=1)
        ...

        self.mainwid.dataCursor.execute("SELECT * FROM MATERIALES WHERE id=?", (gr_ly.id))
        materials = self.mainwid.dataCursor.fetchall()

        for produ in materials:
            self.DatosLayoutCI = DatosLayoutCI(self.mainwid)    # Datos = Data
            ...    
            gr_ly.add_widget(self.DatosLayoutCI)

    self.mainwid.dataBase.commit()   #DISCOMMENT NECCESARY
    self.mainwid.dataBase.close()
self.LayoutGeneralCI.ids.var.add_widget(self.DatosLayoutCI)
File "kivy\properties.pyx", line 841, in kivy.properties.ObservableDict.__getattr__
 AttributeError: 'super' object has no attribute '__getattr__'
gr_ly = GridLayout(id=str(i[1]))

#####adding a widget to the personalized id of layout

gr_ly.add_widget(self.DatosLayoutCI)

self.LayoutGeneralCI.ids.realll.add_widget(gr_ly)

#######all the code is in a function so i want to créate a layout that will #######contain the widgets with a personalized id and then calling the #######personalized id to add the widget in different and specific layouts##

####defining the layout and it's personalized id and adding to the class

gr_ly = GridLayout(id=str(i[1]))

#####adding a widget to the personalized id of layout

gr_ly.add_widget(self.DatosLayoutCI)

self.LayoutGeneralCI.ids.realll.add_widget(gr_ly)#####1 PRIMERA OPCION