属性错误:从 kv 语言调用函数时,“NoneType”对象没有属性“bind”

问题描述 投票:0回答:1

在 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")
kivy attributes bind non-type
1个回答
0
投票

我认为你只需要将

app.again()
的调用移到
app.stop()
的调用之前,这样当
app
被调用时
None
就不是
app.again()
了。

© www.soinside.com 2019 - 2024. All rights reserved.