title: Update a Tkinter text widget as it's written rather than after the class is finished
body: <p>I'm in a bind, since this is being written on a classified machine I am unable to copy+paste here. Being somewhat a novice, my approach is probably unorthodox.</p>
  
  <p>I have a GUI written in Tkinter with several buttons. Each button is linked to a class that, in effect, runs a short script. When the button is clicked, I inititalize a class <code>log_window</code> which is simply a Tkinter text widget. I then create a global variable linking <code>log</code> to the <code>log_window</code> I just created, and as the script runs I pipe <code>sys.stdout/stderr</code> to <code>log</code> (I created a write method specifically for this). Everything is kosher, except that the <code>log_window</code> text widget doesn't update with my piped stdout until after the class calling it is finished.  However, if I simply <code>print</code> within the class, it will print in the order it is called.</p>
  
  <p>Example</p>
  
  <pre><code>import Tkinter
  from Tkinter import *
  import time
  
  class log_window:
      def __init__(self,master):
          self.textframe = Tkinter.Frame(master)
          self.text = Text(self.textframe)
          self.text.pack()
          self.textframe.pack()
      def write(self,text):
          self.text.insert(END,text)
  
  class some_func1: # This effectively waits 5 seconds then prints both lines at once
      def __init__(self,master):
          log.write("some text")
          time.sleep(5)
          log.write("some text")
  
  class some_func2: # This prints the first object, waits 5 seconds, then prints the second
      def __init__(self,master):
          print "some text"
          time.sleep(5)
          print "some text"
  
  if __name__ == '__main__':
      global log    
      root = Tk()
      log = log_window(root)
      root.after(100,some_func1, root)
      root.after(100,some_func2, root)
      root.mainloop()
  </code></pre>
  
  <p>Sorry if my example is a little bit muffed, but I think it makes the point.  The piping I do is through <code>Popen</code> and some system calls, but they aren't part of the issue, so I only highlighted what, I presume, is the LCD of the issue.</p>