AttributeError: ‘’ object has no attribute ‘background_normal’

I am making a mp3 player in kivy and i am facing a problem. i have searched about the solution but none of them works for me. I am getting this error AttributeError: '' object has no attribute 'background_normal' and i am unable to resolve it. please help me.

My python code

class PlaySongScreen(Screen):
    play_btn = ObjectProperty(None)
    def play(self, song_path):
        #function to play the desired song
        if song_path == 'None':
            song_path = songs_list[0]['text']
        mypath = song_path
        mypath = mypath.replace('\', '\\')
        if == 0:
            #playing the song

            #change the play button to pause button
            self.play_btn.background_normal = 'images\new_pause.jpg' 
            self.play_btn.background_down = 'images\pause.jpg'

play_function =

class PlayButton(Factory.Button):
    def on_press(self):
        play_function(PlaySongScreen, song_path=self.text)

My .kv code

    play_btn: play_pause
        cols: 1
        padding: 5
                id: play_pause
                background_normal: 'images\new_play.jpg'
                background_down: 'images\play.jpg'
                size_hint: 0.8, 0.9
                pos_hint: {'center_x': 0.5, 'center_y': 0.5}

error i am getting

File "c:/Users/user/Desktop/Coding/python/Projects/Music Player/", line 126, in on_press
 play_function(PlaySongScreen, song_path=self.text)
 File "c:/Users/user/Desktop/Coding/python/Projects/Music Player/", line 40, in play
 self.play_btn.background_normal = 'images\new_pause.jpg'
 AttributeError: '' object has no attribute 'background_normal'

Please help me resolve this error.


Cannot reproduce your error with the code you have posted. But I suspect that in your actual code you are using PlayButton, which calls If that is what you are actually doing, then that is the cause of your problem. If you access, you are accessing the ObjectProperty, not the Button with id play_pause. You must access the play_btn attribute through the instance of PlaySongScreen, not the the class itself.

The way your posted code does it is correct. Using a Button with on_press set to The root is the instance of PlaySongScreen.