title: Bind on_release in Kivy List item to function
body: <p>I am building a music player that streams from the web, I want to see if it loads locally first before linking the web address</p>
  <p>I want <code>load_songs(path)</code> to got through the list and bind the song name to the one the user clicks on ;</p>
  <p>in other words I want to bind the title of the song to the &quot;id&quot; or property of the list item. I want to use  on_release to play the song.
  With the present code, I get a self not defined error.</p>
  <p>Any help is appreciated</p>
  <p>.py file</p>
  <pre><code>from kivymd.app import MDApp
  from kivymd.icon_definitions import md_icons
  from kivymd.uix.list import OneLineListItem, MDList
  from kivy.properties import StringProperty
  from kivy.uix.screenmanager import ScreenManager,Screen
  from kivy.uix.boxlayout import BoxLayout
  from kivymd.theming import ThemeManager, ThemableBehavior
  from kivy.properties import ObjectProperty
  
  #pygame
  import pygame
  pygame.mixer.init()
  
  path= &quot;C://abapp3&quot;
  
  class MainApp(MDApp):
      def build(self):
          #self.theme_cls.theme_style = &quot;Dark&quot;
          #self.theme_cls.primary_palette = &quot;Indigo&quot;
          #self.theme_cls.accent_palette = &quot;Teal&quot;
          return
  
  
  
  def load_songs(path):
      songs = []
      for filename in os.listdir(path):
              if filename.endswith('.wav'):
                  songs.append(os.path.join(path,filename))
                  self.root.ids.scroll.add_widget(OneLineListItem(text='Genesis', on_release=self.play_song))
  
      return songs
  
  
  songs= load_songs(path)
  
  pygame.mixer.music.load(songs[0])
  
  def play_song():
      pygame.mixer.music.play()
      print('play:', &quot;Genesis&quot;)
  
  
  MainApp().run()
  </code></pre>
  <p>.kv</p>
  <pre><code>Screen:
  
      NavigationLayout:
  
          ScreenManager:
  
              MDScreen:
  
                  BoxLayout:
                      orientation: 'vertical'
                      MDToolbar:
                          title: &quot;Chapters&quot;
                          font_style: &quot;Caption&quot;
                          elevation: 8
                          left_action_items: [['menu', lambda x: nav_drawer.set_state(&quot;open&quot;)]]
  
                      Widget:
  
                  BoxLayout
                      MDLabel
                          id: &quot;genesis&quot;
                          MDList
                              id: &quot;scroll&quot;
                              OneLineListItem
                                  text: &quot;Genesis&quot;
                                  on_release:
  
  
  
  
          MDNavigationDrawer:
              id: nav_drawer
              BoxLayout
                  orientation: &quot;vertical&quot;
                  padding: &quot;8dp&quot;
                  spacing: &quot;8dp&quot;
  
  
                  MDLabel:
                      text: &quot;Options&quot;
                      font_style: &quot;Button&quot;
                      size_hint_y: None
                      height: self.texture_size[1]
  
                  MDLabel:
                      text: &quot;About&quot;
                      font_style: &quot;Caption&quot;
                      size_hint_y: None
                      height: self.texture_size[1]
  
                  ScrollView:
                      MDList:
                          OneLineIconListItem
                              text: 'Storage'
                              IconLeftWidget
                                  icon: 'tools'
  
  
                          OneLineIconListItem
                              text: 'Choose Voice'
                              IconLeftWidget
                                  icon: 'toolbox'
  
                          OneLineIconListItem
                              text: 'About'
                              IconLeftWidget
                                  icon: 'toolbox-outline'
  </code></pre>