我读了这个和那个标签。我有函数回调错误,标签有 NoneType。
class Root(FloatLayout):
def callback( self, label, instance, *args ):
## Try to pass Button.text to the label,
## but type(label) is a NoneType
label.text = instance.text # here
print(label, type(label))
def load_content(self):
content = self.content
for but in range(65, 67):
content.add_widget(Button( text=chr(but),
on_press = partial(self.callback, self.lbl),
font_size=20 ))
content = ObjectProperty(None)
lbl = ObjectProperty(None)