title: Tkinter - create flashing graphic on a canvas?
body: <p>I'm using Tkinter (2.7) to try to create a finite loop that draws, then erases a rectangle on a canvas widget, like its flashing. After several days of trying everything I could find, I have to ask for help.</p>
  
  <p>The problem:</p>
  
  <p>The code below seems to create and delete the rectangle inside the program but not display it in the main window (root).</p>
  
  <pre><code>from Tkinter import *
  root = Tk()
  
  def make():
      canvas.create_rectangle(20,20,60,60,fill="pink")
      root.after(1000)
  
  def unmake():
      canvas.delete(ALL)
      root.after(1000)   
  
  def loop():
      count = 0 
      while count &lt; 5:
          make()
          unmake()
          count += 1
  
  canvas = Canvas(root,width=100,height=100)
  canvas.pack()  
  
  loop()
  
  root.mainloop()
  </code></pre>
  
  <p>Things I've tried:</p>
  
  <p>If I put a print instruction in the make() and unmake() functions these print at 1 second intervals, so I know the .after() method is working.</p>
  
  <p>If I make an infinite loop with the make() function calling unmake() and unmake calling make() again, this does display the flashing rectangle in the main window (root);</p>
  
  <pre><code>def make():
      box = canvas.create_rectangle(20,20,60,60,fill="pink")
      root.after(1000,unmake)
  
  def unmake():
      canvas.delete(ALL)
      root.after(1000,make) 
  </code></pre>
  
  <p>If someone knows why Tkinter is behaving this way, I'd be very grateful for guidance. Thanks.</p>