在 kv 语言中按下此按钮后,我尝试在主应用程序类中调用此函数,但我不断收到 AttributeError: 'NoneType' object has no attribute 'bind',我不知道为什么。我尝试过谷歌搜索,但该错误的解决方案都不适合我。我的代码如下所示(我刚刚留下了应用程序类代码和按钮代码)。如有任何帮助,我们将不胜感激!
class DemoApp(MDApp):
def build(self):
kv = Builder.load_string(""" <CorrectScreen>:
name: "correct"
Button:
background_normal: ''
background_color: (102/255.0, 255/255.0, 0, 1)
font_size: 42
text: "Correct!"
on_release:
app.stop()
app.again()""")
def again(self):
print("hi")
我认为你只需要将
app.again()
的调用移到 app.stop()
的调用之前,这样当 app
被调用时 None
就不是 app.again()
了。