我看过this和that标签。 我有函数回调错误,标签有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)
答案 0 :(得分:0)
查看您传入的内容是否为标签值。
你得到类似的堆栈:
def my_callback(label, instance):
label.text = instance.text
my_callback(None, None)
Traceback (most recent call last):
File "***/vars.py", line 34, in <module>
my_callback(None, None)
File "***/vars.py", line 32, in my_callback
label.text = instance.text
AttributeError: 'NoneType' object has no attribute 'text'
如果是这样,您的源标签是NoneType,您需要将其跟踪。