我需要能够访问布局ID以便为其添加形状。问题是布局的id总是在变化。我将如何获取ID,以便更改特定的布局?
代码:
can = self.root.get_screen("three")
...
get_score = data.get(key, {}).get('score')
new_pos = can.pos
for x in range(-1, get_score): # had to use -1 to get correct amount of shapes
if x % 10 == 0:
layout = GridLayout(id=str(x), cols=1, size_hint= (None,None))
can.ids.my_box.add_widget(layout)
with can.ids.my_box.ids.x.canvas:
Color(0, 1, 0, .75, mode='rgba')
rect = Rectangle(pos=new_pos, size=(30, 30))
new_pos[0] += rect.size[1]
new_pos[0] += rect.size[0]
for child in can.ids.my_box.children: #used to check how many cols are added
print(child.id)
错误:AttributeError: 'super' object has no attribute '__getattr__'