title: PyGTK and Glade 3 - How to get the output of 'print' to TextView
body: <p>I'm quite new in programming, even in speaking in English.. so I'm just trying to explain my problem here:</p>
  
  <p>I'm building a GUI using Glade 3, which need show all output of 'print' in a TextView  or some Widgets else of Glade 3, </p>
  
  <p>My python code is something like this:</p>
  
  <pre><code>#ab.py
  def a():
      print 'AAAAA'
  
  def b():
      print 'BBBBB'
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#button_c.py
  def button_c():
      if:
        print '11111'
      elif:
        print '22222'
      else:
        print '33333'
  
      a()
      b()
  
  if __name__ == '__main__':
  
      button_c()
  </code></pre>
  
  <p>I'm trying use some code like this to show all of the output of 'print' in the object textview1 in a real time, just like the Python Interpreter did:</p>
  
  <pre><code>    def on_button_c_clicked(self, widget):
          button_c()
          self.builder.get_object("textview1").get_buffer().set_text(??????)
  </code></pre>
  
  <p>I've googled a lot and seeing something about sys.stdout, thread, subprocess and textbuffer, but I still can't figure it out, the only idea i have in the moment is change all 'print' parte of the code as:</p>
  
  <pre><code>    def a():
          # print 'AAAAA'
          output_gui = 'AAAAA'
          print output_gui
          self.builder.get_object("textview1").get_buffer().set_text(output_gui)
  </code></pre>
  
  <p>I haven't tried this yet because there must be another smarter way, no?</p>