title: How to update python tkinter window
body: <p>I'm currently trying to update a TKinter window every second. So the idea is that is should open a window, let python updates the field, show updated window. The situation right now is that the second window is only showing when i close the first one. I'm guessing this has something to do with mainloop(). I looked into .update() and .update_idletasks() but I can't figure out how to implement it. TKinter is used to show a field with houses in it. So in general is should do this:</p>
  
  <ul>
  <li>Generate house location (already implemented) </li>
  <li>Show field with houses in it (already implemented)</li>
  <li>Generate new location of houses (already implemented)</li>
  <li>Show updated field</li>
  </ul>
  
  <p>This is my current code. I'm not sure if the update function is necessary. </p>
  
  <pre><code>    class Plot(tk.Frame):
          def __init__(self, master=None):
              tk.Frame.__init__(self, master)
              self.grid()
  
          def createWidgets(self, list_houses):
              houses = list_houses
              self.w = tk.Canvas(self, width = field.width*SIZE, height = field.height*SIZE, bg = '#E4E4E4')
  
              ...
  
              self.w.grid()
  
          def update(self):
              ?
  
  #GENERATES FIELD AND HOUSES
  ...
  
  #PRINT FIRST WINDOW
  plot = Plot()
  plot.createWidgets(houses) &lt;- PUT HOUSES IN TK INTER
  plot.master.title('map of houses')
  plot.mainloop()
  
  # UPDATE FIELD &lt;- THIS PART IS ONLY EXECUTED WHEN I CLOSE THE FIRST WINDOW, WHY?
  i = 0
  while i &lt; 2:
      update = field.update_houses(houses) &lt;- GENERATES NEW LOCATION OF HOUSES
  
      #PRINT UPDATED WINDOW, IT SHOULD BE PRINTED IN THE SAME WINDOW!
      plot = Plot()
      plot.createWidgets(houses) &lt;- PUT HOUSES IN TKINTER
      plot.master.title('map of houses')
  
      i += 1
  </code></pre>
  
  <p>Thanks in advance!</p>