Attributeerror: 'Nonetype' Object has no attribute

Asked

Viewed 1,009 times

0

Hello, I’m doing some testing with the framework Kivy and this error is being presented to me:

AttributeError: 'NoneType' object has no attribute 'text'

Well, follow the code Python:

class Window(BoxLayout):

    text = StringProperty('Nome')
    screen_manager = ScreenManager()

    def __init__(self, **kwargs):

        super(Window, self).__init__(**kwargs)


class Main(App):

    def build(self):

        return Window()


if __name__ == '__main__':

    Main().run()

And the code in KV language:

<Window>:
    Screen:
        BoxLayout:
            Button:
                text: app.root.text
  • The object app.root apparently not defined.

  • I also realized that, and I thought it was strange the obese being None, but according to the documentation (https://kivy.org/docs/api-kivy.app.html?highlight=app%20root#kivy.app.App.root), the object root is set automatically by the method build (in this case).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.