- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我读了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)
最佳答案
查看您作为标签值传递的内容。
你有没有得到类似这样的堆栈:
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,您将需要对其进行追踪。
关于Python - 如何使用多个参数在 Kivy 上绑定(bind) Button on_press,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19796866/
我遇到过这个 html: 上面的html和这个有什么区别: 最佳答案 来自MDN page on the tag : 对于 type 的属性标签,可能的值是: 提交:按钮将表单数据提交给服务器
Button button= (Button) findViewbyID(R.id.button); 和 Button button = new Button(this); 有什么区别? 最佳答案 有
我是一名优秀的程序员,十分优秀!