简体   繁体   English

屏幕管理器AttributeError:“超级”对象没有属性“ __getattr__”

[英]Screen manager AttributeError: 'super' object has no attribute '__getattr__'

I use ScreenManager in project. 我在项目中使用ScreenManager。 When I return "Home" class in Main.py it works correctly but ı return "ScreenManager" it get AttributeError.How can ı fix it. 当我在Main.py中返回“ Home”类时,它可以正常工作,但是如果返回“ ScreenManager”,它将得到AttributeError。如何修复它。

Main.py 主程序

from kivy.app import App
from kivy.lang.builder import Builder
from Components.Home.HomeScreen import Home,EachTask
from Components.SM.SM import SM
Builder.load_file("Components/SM/SM.kv")
Builder.load_file("Components/Home/HomeScreen.kv")
class Main(App):
    def build(self):
        return SM()

if  __name__ == "__main__":
    Main().run()

when I return Home() it works but I return SM is not work 当我返回Home()时有效,但我返回SM则无效

HomeScreen.py HomeScreen.py

class Home(Screen):


def __init__(self,**kwargs):
    super(Home,self).__init__(**kwargs)
    EachTask.Remove_widget = self.remove_widget
    MyPopup.Remove_widget = self.remove_widget_pop
    EachTask.Do_Popup_Task = self.do_popup_task




    for row in database:


        if (row[3]) == True:
            newListItem = EachTask(rgba=[0, .7, .3, 1],
                                   text= row[0] + "    time:    " + row[1],
                                   id=row[2])
            self.ids.add_field.add_widget(newListItem)

        else:

                newListItem = EachTask(text=row[0] + "    time:    " + row[1],
                                       id=row[2])

                self.ids.add_field.add_widget(newListItem)

Error 错误

   self.ids.add_field.add_widget(newListItem)
   File "kivy\properties.pyx", line 863, in 
   kivy.properties.ObservableDict.__getattr__
   AttributeError: 'super' object has no attribute '__getattr__'

There's nothing much to say without looking at the kv file and the py file. 如果不查看kv文件和py文件,没有什么可说的。 But, just to check 但是,只是检查

self.ids.add_field.add_widget(newListItem)

this line would add the newListItem to the Layout which is defined in .kv file . 这行代码会将newListItem添加到.kv file定义的Layout中。 the id: of the this layout needs to be add_field as well 此布局的id:也需要为add_field

for example (kv file): 例如(kv文件):

<Home>:
  GridLayout:
     id:add_field
     cols:2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 屏幕管理器(AttributeError:“ super”对象没有属性“ __getattr__”) - screen manager (AttributeError: 'super' object has no attribute '__getattr__') AttributeError:“超级”对象没有属性“ __getattr__” - AttributeError: 'super' object has no attribute '__getattr__' AttributeError:“超级”对象没有属性“ __getattr __”(我进行了搜索,但无济于事) - AttributeError: 'super' object has no attribute '__getattr__' ( I searched, but to no avail) AttributeError: &#39;super&#39; 对象在 python 中没有属性 &#39;__getattr__&#39; - AttributeError: 'super' object has no attribute '__getattr__' in python Kivy: AttributeError: 'super' object 没有属性 '__getattr__' - Kivy: AttributeError: 'super' object has no attribute '__getattr__' Kivy AttributeError: 'super' object 没有属性 '__getattr__' - Kivy AttributeError: 'super' object has no attribute '__getattr__' Kivy AttributeError: 'super' object has no attribute '__getattr__' 错误 - Kivy AttributeError: 'super' object has no attribute '__getattr__' error Python Kivy 返回 'AttributeError: 'super' object 没有属性 '__getattr__'' - Python Kivy returning 'AttributeError: 'super' object has no attribute '__getattr__'' KIVY 错误:AttributeError:&#39;super&#39; 对象没有属性 &#39;__getattr__&#39; - KIVY ERROR: AttributeError: 'super' object has no attribute '__getattr__' python kivy AttributeError:“超级”对象没有属性“ __getattr__” - python kivy AttributeError: 'super' object has no attribute '__getattr__'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM