title: Kivy - Accessing Elements of a ListProperty in .kv file
body: <p>I have started programming with Kivy, the amazing open-source GUI library in Python.</p>
  
  <p>I came accross a problem <a href="https://stackoverflow.com/questions/27836381/listproperty-item-by-index-in-kv">close to this topic</a> but it has no satisfying answer.</p>
  
  <p>I want to access the elements of a ListProperty attached to my widget in my .kv file but I get an error. I guess it comes from a misunderstanding of the KV syntax but I cannot quite figure out what's happening.</p>
  
  <p>More precisely, I get the following error: </p>
  
  <ul>
  <li>Builder exception: Parser: on the line I have commented (see below .kv file)</li>
  <li>IndexError: list index out of range</li>
  </ul>
  
  <p>It is as if the builder did not understand that my <strong>custom_list</strong> has indeed 3 elements indexed from 0 to 2.</p>
  
  <p>Here is the simple example I coded to illustrate the situation :</p>
  
  <p><strong>example.py file</strong></p>
  
  <pre><code># Kivy modules
  import kivy
  from kivy.uix.boxlayout import BoxLayout
  from kivy.uix.label import Label
  from kivy.app import App
  from kivy.properties import ListProperty
  
  
  
  class MyCustomLabel(Label):
      custom_list = ListProperty()
  
  
  class MainWidget(BoxLayout):
  
      def generate_list(self):
          l = ["Hello","Amazing","World"]
          my_custom_label = MyCustomLabel()
          my_custom_label.custom_list = l
          self.add_widget(my_custom_label)
  
  
  class MyApp(App):
      pass
  
  if __name__=="__main__":
      MyApp().run()
  </code></pre>
  
  <p><strong>my.kv file</strong></p>
  
  <pre><code>&lt;MainWidget&gt;:
      orientation: "vertical"
  
      Button:
  
          # Aspect
          text: "CLICK ME"
          size_hint_y: None
          height: dp(60)
  
          # Event
          on_press: root.generate_list()
  
  
  &lt;MyCustomLabel&gt;:
  
      ## This is working
      ## text: "{}".format(self.custom_list)
  
      ## But this is not working... Why ?
      text: "{}{}{}".format(self.custom_list[0], self.custom_list[1], self.custom_list[2])
  
  MainWidget:
  </code></pre>
  
  <p>Thanks in advance for those who will take the time to answer,</p>
  
  <p>M</p>