title: Why isn't the label animation working till the last value of the loop?
body: <p>I am new to python and I have been learning tkinter recently. So I thought with myself that using the <strong>grid_forget()</strong> function I can remove a widget and redefine it. I thought of this animation that changes the padding of a label so it would create space (kind of like moving the label but not exactly). However, the animation does not work at all. The program freezes until the label reaches the last value of the padding. How can I fix this? Or is there a better way to animate a label moving in the screen?
  Here is my code:</p>
  <pre><code>from tkinter import *
  import time
  
  root = Tk()
  lbl = Label(root, text='------')
  lbl.grid(row=0, column=0)
  
  
  def animation():
      padding = 0
      while padding &lt; 31:
          lbl.grid_forget()
          padding += 1
          lbl.grid(row=0, column=0, padx=padding)
          time.sleep(0.2)
          # alternative: root.after(200, lambda: lbl.grid(row=0, column=0, padx=padding))
  
  
  btn = Button(root, text='Animate', command=animation)
  btn.grid(row=1, column=1)
  root.mainloop()
  </code></pre>