help with AttributeError: object has no attribute

515 views
Skip to first unread message

Gabriel de Jesus

unread,
Dec 8, 2022, 7:10:26 PM12/8/22
to kivy-...@googlegroups.com
Good evening. I am having trouble understanding an error in the project I am working on. I am creating a function to change pages in a registration form, so I create the "next" function and refer to the "on_release" event in my KV code. However, when I run the application, the terminal gives me the error "AttributeError: object has no attribute". Can someone help me? Below is the code. Thank you in advance and I will be grateful for any help.

return at the terminal:
image.png

code:
import os
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import Screen


Builder.load_string(
    """

<forget_password>:
    MDFloatLayout:
        md_bg_color: rgba(240, 240, 240, 240)
        MDFloatLayout:
            size_hint: 1, .1
            pos_hint: {"center_y": .95}
           
            canvas:
                Color:
                    rgba: app.theme_cls.primary_color
                RoundedRectangle:
                    pos: self.pos
                    size: self.size
                    radius: [0, 0, 15, 15 ]

            MDLabel:
                text: "Password Recovery"
                font_size: "19sp"
                color: 1, 1, 1, 1
                font_name: "fontes/RobotoCondensed-Bold.ttf"
                halign: "center"
                pos_hint: {'center_x': 0.5,'center_y': 0.5}  

            MDIconButton:
                icon: "arrow-left"
                pos_hint: {'center_x': 0.1,'center_y': 0.5}
                theme_icon_color: "Custom"
                icon_color: 1, 1, 1, 1

        MDFloatLayout:
            MDCard:
                size_hint: .8, .45
                pos_hint: {"center_x": .5, "center_y": .5}
                elevation: 3
                shadow_softness: 8
                Carousel:
                    id: slide
                    MDFloatLayout:
                        MDLabel:
                            text: "Please enter the registered email address"
                            font_name: "fontes/Poppins/Poppins-Regular.ttf"
                            font_size: "12sp"
                            pos_hint: {"center_x": .5, "center_y": .8}
                            halign: "center"
                            opacity: .7

                        MDTextField:
                            hint_text: "mail"                        
                            size_hint_x: .8
                            pos_hint: {"center_x": .5, "center_y": .58}

                        MDRaisedButton:
                            text: "Send"
                            pos_hint: {"center_x": .5, "center_y": .25}
                            font_name: "fontes/RobotoCondensed-Bold.ttf"
                            font_size: "16sp"
                            size_hint_x: .8
                            on_release: app.next() #event reference to function

fff
                    MDFloatLayout: #sends a 6-digit verification code to the registered email address
                        MDLabel:
                            text: " Enter the verification code that we sent to the informed e-mail"
                            font_name: "fontes/Poppins/Poppins-Regular.ttf"
                            font_size: "12sp"
                            pos_hint: {"center_x": .5, "center_y": .8}
                            halign: "center"
                            opacity: .7

                        MDFloatLayout:
                            size_hint: .8, .18
                            #md_bg_color: 0, 0, 0, 1
                            pos_hint: {"center_x": .5, "center_y": .53}
                           
                             
                            MDTextField:
                                id: cx_1
                                hint_text: ""  
                                halign: "center"                        
                                size_hint_x: .13
                                pos_hint: {"center_x": .03, "center_y": .58}
                               
                                   
                            MDTextField:
                                id: cx_2
                                hint_text: ""
                                halign: "center"                          
                                size_hint_x: .13
                                pos_hint: {"center_x": .22, "center_y": .58}
                           
                            MDTextField:
                                id: cx_3
                                hint_text: ""
                                halign: "center"                        
                                size_hint_x: .13
                                pos_hint: {"center_x": .42, "center_y": .58}
                           
                            MDTextField:
                                id: cx_4  
                                hint_text: ""
                                halign: "center"                          
                                size_hint_x: .13
                                pos_hint: {"center_x": .6, "center_y": .58}

                            MDTextField:
                                id: cx_5
                                hint_text: ""  
                                halign: "center"                        
                                size_hint_x: .13
                                pos_hint: {"center_x": .78, "center_y": .58}
                             

                            MDTextField:
                                id: cx_6
                                hint_text: ""  
                                halign: "center"                
                                size_hint_x: .13
                                pos_hint: {"center_x": .97, "center_y": .58}
                                 
                 
                        #user authentication      
                        MDRaisedButton: #Button
                            text: "Next"
                            pos_hint: {"center_x": .5, "center_y": .25}
                            font_name: "fontes/RobotoCondensed-Bold.ttf"
                            font_size: "16sp"
                            size_hint_x: .8

"""
)

class forget_password(Screen):
   

    def next(self):
        self.root.ids.slide_load.next(mode='next')


Elliot Garbus

unread,
Dec 8, 2022, 7:22:09 PM12/8/22
to kivy-...@googlegroups.com

on_release: app.next()   #event reference to function

 

The problem is that the next() method is not defined in app, it is defined in forgot_passwords.  Change the on_release line:

 

on_release: root.next()   #event reference to function

 

in kv, root refers to the enclosing class. Or the root widget of the kv rule.  See: https://kivy.org/doc/stable/api-kivy.lang.html?highlight=lang#value-expressions-on-property-expressions-ids-and-reserved-keywords

 

 

From: Gabriel de Jesus
Sent: Thursday, December 8, 2022 5:10 PM
To: kivy-...@googlegroups.com
Subject: [kivy-users] help with AttributeError: object has no attribute

 

Good evening. I am having trouble understanding an error in the project I am working on. I am creating a function to change pages in a registration form, so I create the "next" function and refer to the "on_release" event in my KV code. However, when I run the application, the terminal gives me the error "AttributeError: object has no attribute". Can someone help me? Below is the code. Thank you in advance and I will be grateful for any help.

 

return at the terminal:

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CALSY6AT9SAeU8CxJVT_2e340ydPAO_uTXfeO4ox1zSS9y1daUw%40mail.gmail.com.

 

Gabriel de Jesus

unread,
Dec 8, 2022, 10:08:58 PM12/8/22
to kivy-...@googlegroups.com
thank you very much. It worked out well! 


Reply all
Reply to author
Forward
0 new messages