[英]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。如何修复它。
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则无效
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)
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.