title: Substituting text inside buttons with widgets
body: <p>My app (using kivy) needs to substitute text with widgets inside an unspecified number of buttons using iteration. I don't use kv language. Only the last button displays any content.</p>
  <p>My app should display an unspecified number of buttons. Simplified example:</p>
  <pre><code>import kivy
  kivy.require('2.0.0')
  
  from kivy.app import App
  from kivy.core.window import Window
  from kivy.uix.widget import Widget
  from kivy.uix.boxlayout import BoxLayout
  from kivy.uix.anchorlayout import AnchorLayout
  from kivy.uix.gridlayout import GridLayout
  from kivy.uix.button import Button
  from kivy.uix.label import Label
  from kivy.uix.image import Image
  
          
  class Layout(Widget):
      def __init__(self, app):
          super().__init__()
          
          self.layout = BoxLayout(orientation='vertical', size=Window.size)
          
          contents = ['text1', 'text2', 'text3']
          for text in contents:
              button = Button(height=300, size_hint=(1, None))
              
              button.text = text
  
              self.layout.add_widget(button)
          
          self.add_widget(self.layout)
    
  
  class MyApp(App):
      def build(self):
          self.form = Layout(self)
          return self.form
  
      def on_pause(self):
          return True
  
  if __name__ in ('__main__', '__android__'):
      MyApp().run()
  </code></pre>
  <p>Only instead of text buttons display images with descriptions. I change the code:</p>
  <pre><code>import kivy
  kivy.require('2.0.0')
  
  from kivy.app import App
  from kivy.core.window import Window
  from kivy.uix.widget import Widget
  from kivy.uix.boxlayout import BoxLayout
  from kivy.uix.anchorlayout import AnchorLayout
  from kivy.uix.gridlayout import GridLayout
  from kivy.uix.button import Button
  from kivy.uix.label import Label
  from kivy.uix.image import Image
  
          
  class Layout(Widget):
      def __init__(self, app):
          super().__init__()
          
          self.layout = BoxLayout(orientation='vertical', size=Window.size)
          
          contents = [('img1', 'text1'), ('img2', 'text2'), ('img3', 'text3')]
          for img, text in contents:
              button = Button(height=300, size_hint=(1, None))
              
              button_layout = BoxLayout(orientation='vertical', size_hint=(1, 1))
              label = Label(text=text)
              image = Image(source=f'{img}.jpg', size_hint=(1, 1), allow_stretch=True)
              button_layout.add_widget(image)
              button_layout.add_widget(label)
              button.add_widget(button_layout)
              
              self.layout.add_widget(button)
          
          self.add_widget(self.layout)
          
  
  class MyApp(App):
      def build(self):
          self.form = Layout(self)
          return self.form
  
      def on_pause(self):
          return True
  
  if __name__ in ('__main__', '__android__'):
      MyApp().run()
  </code></pre>
  <p>And only the last button displays content.</p>
  <p>As far as I can understand, at some point Python automatically gets read of the content of the previous button. How can I prevent it? Also what is the best way to center it?
  I'm not a native speaker, so sorry for bad grammar. Thank you in advance.</p>