'Python Kivy: 'kivy.properties.ObjectProperty' object has no attribute 'text'

I have only been looking into kivy for about 1 week for a school project, so I'm new to this module. I'm trying to do a login form where the program get the username and password input by the user and verify it with the database. However I have been stuck with this

File "C:\Users\binch\PycharmProjects\catmostphere\src\view\login\__init__.py", line 20, in LogBtn
 user = src.controller.Login.Verifying(src.controller.Login, self.username.text, self.password.text)

AttributeError: 'kivy.properties.ObjectProperty' object has no attribute 'text'

. I've tried some solutions I found online but so far nothing seems to work. Can someone help me? Here is the code:

from kivy.app import App
from kivy.lang import Builder
from kivy.properties import ObjectProperty
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import Screen, ScreenManager
import src.controller


class LoginScreen(Screen):
  username = ObjectProperty(None)
  password = ObjectProperty(None)

  def reset(self):
    self.username.text = ""
    self.password.text = ""


  def LogBtn(self):
     user = src.controller.Login.Verifying(src.controller.Login, self.username.text, self.password.text)
     src.controller.Login.Login(src.controller.Login, user)
     LoginScreen.reset(self)
     return user

  class MainScreen(Screen):
     pass


  class WindowManager(ScreenManager):
     pass


  def invalidLogin():
     pop = Popup(title='Invalid Login',
            content=Label(text='Invalid username or password.'),
            size_hint=(None, None), size=(300, 200))
     pop.open()


     kv = Builder.load_string('''
<LoginScreen>
    name: "first"

    username: username
    password: password

    FloatLayout:

        Label:
        text: "Username: "
        font_size: (root.width **2 + root.height**2)/ 13**4
        pos_hint: {"x": 0.1, "top": 0.75}
        size_hint: 0.3, 0.15

    TextInput:
        id: username
        font_size: (root.width **2 + root.height**2)/ 13**4
        multiline: False
        pos_hint: {"x": 0.45, "top": 0.75}
        size_hint: 0.4, 0.15

    Label:
        text: "Password: "
        font_size: (root.width **2 + root.height**2)/ 13**4
        pos_hint: {"x": 0.1, "top": 0.5}
        size_hint: 0.3, 0.15

    TextInput:
        id: password
        font_size: (root.width **2 + root.height**2)/ 13**4
        multiline: False
        password: True
        pos_hint: {"x": 0.45, "top": 0.5}
        size_hint: 0.4, 0.15

    Button:
        pos_hint:{"x":0.4, "y":0.2}
        size_hint:0.3, 0.05
        font_size: (root.width **2 + root.height**2)/ 13**4
        text:"Login"
        on_release:
            root.LogBtn()

 <MainScreen>
    name: "main"

    GridLayout:
      cols : 1
    Label:
        text: "haha"

''')

   sm = WindowManager()

   screens = [LoginScreen(name="first"), MainScreen(name="main")]
   for screen in screens:
      sm.add_widget(screen)

   sm.current = "first"


   class MyMainApp(App):
      def build(self):
      return sm


   if __name__ == "__main__":
      MyMainApp().run()

P.s This is my first time asking something so sorry for the messy format.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source