title: send the output of print() to tkinter Text widget
body: <p>I wrote a python 3.4.2 programme to get a user input from python IDLE, perform some processing on the input and display a few statements in the python IDLE using print().</p>
  
  <p>Now I am in the process of converting this to use a GUI using tkinter. This is the simple tkinter code I wrote for the GUI.</p>
  
  <pre><code>from tkinter import *
  root=Tk()
  root.title("Post-fix solver")
  root.geometry("500x500")
  mainframe=Frame(root)
  mainframe.grid(column=0, row=0)
  
  inputval=StringVar()
  inputentry=Entry(mainframe,textvariable=inputval).grid(column=1,row=1)
  
  executebutton=Button(mainframe,text="Run",command=check_expression).grid(column=1,row=5)              
  
  outputtext=Text(mainframe).grid(column=1,row=5)
  
  root.mainloop()
  </code></pre>
  
  <p>So far I was able to get the user input through the Entry widget named inputentry in the GUI and send it to a variable in the original code using inputval.get(). Then it performs the processing on the input and shows the outputs of print() statement in the python IDLE.</p>
  
  <p>My question is how can I modify the programme to send all those print() statements to the Text widget named outputtext and display them in the GUI?</p>
  
  <p>I would be glad if you could show me how to do this without using classes as I am a beginner in python </p>