title: In Kivy, how can I animate a series of widgets with a loop?
body: <p>I am writing an app in which I've run into a situation where I would like to animate a series of objects sequentially by iterating through a for loop. </p>
  
  <p>When I run the app and click the button, I want the first label's text to shrink, wait for a 1.5s pause, the second label to shrink, wait, shrink, wait, shrink, etc. However, when it's run, though the app sleeps for each of the 1.5 seconds, none of the animations occur until after the for loop has run it's course, and then they all run at once. </p>
  
  <p>I've pared the problem code out of my main code below and the issue still persists. Does anyone have a solution or an alternative? I suspect it has something to do with multithreading, but that's just a guess. I've tried decorating <strong>shrinkray</strong> with @mainthread, but it doesn't seem to make a difference.</p>
  
  <pre><code>from kivy.app import App
  from kivy.uix.gridlayout import GridLayout
  from kivy.uix.label import Label
  from kivy.animation import Animation
  from kivy.uix.button import Button
  import time
  
  class Test(GridLayout):
      def __init__(self, **kwargs):
          super(Test, self).__init__(**kwargs)
          self.cols = 2
          self.thislabel1 = Label(text="One")
          self.add_widget(self.thislabel1)
          self.thislabel2 = Label(text="Two")
          self.add_widget(self.thislabel2)
          self.thislabel3 = Label(text="Three")
          self.add_widget(self.thislabel3)
          self.thislabel4 = Label(text="Four")
          self.add_widget(self.thislabel4)
          self.thislabel5 = Label(text='Five')
          self.add_widget(self.thislabel5)
          self.button1 = Button(text='Shrink Ray')
          self.button1.bind(on_release=self.shrinkray)
          self.add_widget(self.button1)
          self.these_children = [self.thislabel1,self.thislabel2,self.thislabel3,self.thislabel4,self.thislabel5]
  
      def shrinkray(self,*args):
          anim = Animation(font_size=1)
          for these_labels in self.these_children:
              anim.start(these_labels)
              time.sleep(1.5)
  
  
  class MyApp(App):
      def build(self):
          return Test()
  
  if __name__ == '__main__':
      MyApp().run()
  </code></pre>