How to reinitialize text widget in Tkinter?
<p>I am trying to return the search result of the user in the GUI itself.
This is the following code which I am using </p>

<pre><code>def printResult(searchResult):
global resultsFrame
text = Text(resultsFrame)

for i in searchResult:
    text.insert(END,i+'\n')
text.pack(side=TOP) 
</code></pre>

<p>where searchResult is a list which has all the statements to be printed on the screen and this is how I declared resultsFrame in the code (before root.mainloop())
I am using global so that it makes changes to the existing frame but it rather adds another frame below it.
How to make changes in the already existing text widget?</p>

<pre><code>resultsFrame = Frame(root)
resultsFrame.pack(side=TOP)
</code></pre>

<p>For reference here is an image of the GUI:</p>

<p><a href="http://i.stack.imgur.com/anajN.png" rel="nofollow"><img src="http://i.stack.imgur.com/anajN.png" alt="Creation of new Text widget"></a></p>

<p>EDIT : 
<strong><em>Issue Solved</em></strong></p>

<p>I declared the frame outside the function</p>

<pre><code>resultsFrame = Frame(root)
resultsFrame.pack(side=TOP)
text = Text(resultsFrame)

def printResult(searchResult):
   global resultsFrame
   global text
   text.delete("1.0",END)
   for i in searchResult:
       text.insert(END,str(i)+'\n')
   text.pack(side=TOP) 
</code></pre>

<p>Try this:</p>

<pre><code>global resultsFrame
text = Text(resultsFrame)

def printResult(searchResult):
    for i in searchResult:
        text.insert(END,i+'\n')
...
text.pack(side=TOP) 
</code></pre>

<p>This should solve your issue.</p>

python python-2.7 user-interface tkinter