Python Tkinter updating text-box content via a function
<p>Beginner programmer here, working on making a basic GUI as part of a tutorial I was following online, but none of them say how to get a Text box to update using the output of the other parts of your code.</p>

<p>I tried multiple other answers on the site, including one using StringVar's, which got me nowhere, another using a decorator, and the rest seemed way out of my depth.</p>

<p>Here's my code:</p>

<pre><code>import tkinter as tk

import time
#Creating Root
root = tk.Tk()


#GUI TEMPLATE


frame =tk.Frame(root,
            height = 100,
            width = 400)
frame.pack()
v = StringVar()

colour = ["red","blue","green","white","yellow"]
labels = range(5) 
#change number to change how many labels
for i in range(5):
    l= tk.Label(root,
            text = colour[i],
            bg = colour[i])
    l.place(x = 10 +i*70, y = 10, width=60, height=25)




T1 = tk.Text(root, height=2, width=40)
words = "Don't name your files after module names!"
T1.insert(tk.END, textvariable=v)

T1.place(x = 10, y= 40)

S = tk.Scrollbar(root)
S.config(command=T1.yview)
S.place(x = 340, y=40)

T1.config(yscrollcommand=S.set)

root.mainloop()

v.set("Something Else!")
</code></pre>

<p>Now, what it should output is a row of coloured labels, which works fine, and a text box with a scroll bar, which should instantly update to read 'Something Else!', which does not work fine.</p>

<p>Instead I get the following error:</p>

<p>NameError: name 'StringVar' is not defined</p>

<p>I know what this error means, it's just I've hit a wall when it comes to finding a solution that works for me, and doesn't need a doctorate to understand.</p>

<p>What I'm asking for is if someone can give me a solution that would work for this, and hopefully explain it! </p>

<p>Thanks in advance. </p>

<p><strong>EDIT:</strong>
So after fixing the syntax error, and then finding out what I'm trying to do doesn't work, how would I go about this?</p>

<p>Could I use a label instead? Or is there another, better way? 
Thanks again!</p>