GridLayout
对象在网格内生成网格。以下是我的代码的简化版本:
class SettingsPanel(GridLayout):
def __init__(self, *args):
GridLayout.__init__(self, cols=2);
self.add_widget(Label(text='SubSubFoo'))
self.add_widget(Label(text='SubSubFoo2'))
class Panel(GridLayout):
def __init__(self, *args):
GridLayout.__init__(self, cols=1);
self.add_widget(Label(text='SubFoo'))
self.my_second_layer_grid = SubSubGrid()
self.add_widget(self.my_second_layer_grid)
class GUI(App):
def build(self):
self.title = "My app"
layout = GridLayout(cols=2)
layout.add_widget(Label(text='Foo'))
self.my_panel = SubGrid()
layout.add_widget(self.my_panel)
return layout
if __name__ == '__main__':
GUI().run()
尽管我成功地运用了我所说的
SubGrid
,在我插入
SubSubGrid
self.my_second_layer_grid = SubSubGrid()
...
BuilderException: Parser: File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\myenv\lib\site-packages\kivy\data\style.kv", line 871:
...
869: Label:
870: size_hint_y: None
>> 871: text: root.title
872: text_size: self.width - 32, None
873: height: max(50, self.texture_size[1] + 20)
...
AttributeError: 'SettingsPanel' object has no attribute 'title'
怎么了?
Kivy在分析
Label
s码?如果是,为什么它不
text
子网格
编辑: