Turn weak reference to strong

206 views Asked by At

In my code label object is weakly referenced. How can I turn it to strongly referenced one? I got the error 'weakly referenced object no longer exists'. Will increasing the references to that object help?

from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout

class Audioplayer(App):
    def build(self):
        layout = GridLayout(cols = 2 )
        btn = Button(text = "Arey Band kar")
        lbl = Label(text = "gaana ban Raha hai")

        music = SoundLoader.load("prb.mp3")

        if music:
            music.play()

        layout.add_widget(btn)
        layout.add_widget(lbl)

        return layout
        
Audioplayer().run()
0

There are 0 answers