Hey everyone I want to verify a text input and it doesn't work. I don't know why. Here is the code, btw I tried EVERYTHING and it doesn't work so don't talk about self.root.ids.id.text, IT JUST DOESN'T WORK. :
class ReviewinApp(MDApp):
def build(self):
dialog = None
self.title = "ReviewinApp"
global sm
sm = ScreenManager()
sm.add_widget(Builder.load_file("splash.kv"))
sm.add_widget(Builder.load_file("accueil.kv"))
sm.add_widget(Builder.load_file('conditions.kv'))
sm.add_widget(Builder.load_file("register.kv"))
sm.add_widget(Builder.load_file("faq.kv"))
sm.add_widget(Builder.load_file("login.kv"))
sm.add_widget(Builder.load_file("User2.kv"))
sm.add_widget(Builder.load_file("rules.kv"))
sm.add_widget(Builder.load_file("commentinput.kv"))
sm.add_widget(Builder.load_file("UserInfo.kv"))
return sm
def check_text(self):
if self.ids.full_name.text == 'g':
print("g")
else:
return False
MDScreen:
name:"register"
MDFloatLayout:
md_bg_color: 41/255, 34/255, 34/255, 1
MDTextFieldRound:
id:full_name
text: ""
hint_text: "Full Name"
size_hint_x: None
size_hint_y: 0.08
width: 247
font_size: 18
pos_hint: {'center_x':0.5, 'center_y':0.7}
MDFillRoundFlatButton:
text: "Finish !"
font_size: "20sp"
font_name: "OpenSans"
pos_hint: {'center_x':0.5, 'center_y':0.1}
halign: 'center'
theme_text_color:'Custom'
text_color: 255/255, 255/255, 255/255, 1
size_hint: (0.58, 0.06)
md_bg_color: 62/255, 216/255, 133/255, 1
background_normal:''
on_press: app.check_text()
I don't get that error, but I do get an error.
If you access an id
that is defined in a kv
file, you must access it through the ids
of the object that is the root object that contains that id
. In this case, the full_name
id
is defined in the kv
that you posted. The root that contains the id
is the MDScreen
, so you must access it through the ids
of that MDScreen
:
def check_text(self):
if self.root.current_screen.ids.full_name.text == 'g':
print("g")
else:
return False