Testing an app out and I can't find a way to get the input from the text field. I want to be able to get the input of the username and password and use it plug in SQL to get data from a certain account. From what I understand, I can press the submit button and the function i called s1 should be called and print my input but im getting this error:
File "C:/Users/63917/PycharmProjects/kivymd/mobile.py", line 121, in s1
print(self.root.ids.userdata.text)
File "kivy\properties.pyx", line 863, in kivy.properties.ObservableDict.__getattr__
AttributeError: 'super' object has no attribute '__getattr__'
screen_helper = """
ScreenManager:
MenuScreen:
SubmitScreen:
UploadScreen:
<MenuScreen>:
name: 'menu'
MDTextField:
id: userdata
hint_text: "Enter Username"
helper_text: "or click on forgot username"
#helper_text_mode: "persistent"
helper_text_mode: "on_focus"
icon_right: "account"
icon_right_color: app.theme_cls.primary_color
pos_hint : {'center_x': 0.5, 'center_y': 0.8}
size_hint_x:None
width:250
mode : "rectangle"
MDTextField:
hint_text: "Enter Password"
helper_text: "or click on forgot Password"
#helper_text_mode: "persistent"
password : True
# password_mask : "*"
helper_text_mode: "on_focus"
icon_right: "eye-off"
icon_right_color: app.theme_cls.primary_color
pos_hint : {'center_x': 0.5, 'center_y': 0.7}
size_hint_x:None
width:250
mode : "rectangle"
MDLabel:
text: "Lil's Lending Shop"
pos_hint: {'center_x':0.8, 'center_y':0.9}
MDRectangleFlatButton:
text: 'Submit'
pos_hint: {'center_x':0.5, 'center_y':0.4}
font_size : 20
#on_press: root.manager.current = 'submit'
MDRectangleFlatButton:
text: 'Upload'
pos_hint: {'center_x':0.5, 'center_y':0.5}
on_press: root.manager.current = 'upload'
<SubmitScreen>:
name: 'submit'
MDLabel:
text: 'Welcome Oliver'
halign: 'center'
MDRectangleFlatButton:
text: 'Menu'
pos_hint: {'center_x':0.5, 'center_y':0.2}
on_press: root.manager.current = 'menu'
<UploadScreen>:
name: 'upload'
MDLabel:
text: 'upload daw ek ek'
halign: 'center'
MDRectangleFlatButton:
text: 'Menu'
pos_hint: {'center_x':0.5, 'center_y':0.2}
on_press: root.manager.current = 'menu'
"""
class MenuScreen(Screen):
pass
class SubmitScreen(Screen):
pass
class UploadScreen(Screen):
pass
sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))
sm.add_widget(SubmitScreen(name='submit'))
sm.add_widget(UploadScreen(name='upload'))
class DemoApp(MDApp):
def build(self):
screen = Builder.load_string(screen_helper)
return screen
def s1(self):
print(self.root.ids.userdata.text)
DemoApp().run()