Referenced before assignment - tkinter
<p>I'm not sure why I get an error message when I click on get button. I've moved things around and I still get this error message.</p>

<pre><code>Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.4/tkinter/__init__.py", line 1536, in __call__
     return self.func(*args)
  File "address.py", line 5, in getName
     first_name = first_name.get()
UnboundLocalError: local variable 'first_name' referenced before assignment
</code></pre>

<p>Code:</p>

<pre><code>from tkinter import *
from tkinter import ttk

def getName(event):
    first_name = first_name.get()
    fieldEntry.insert(0, first_name)

root = Tk()
root.title('Address Book')
Label(root, text='First Name').grid(row=0, sticky=W, padx=4)
first_name = Entry(root).grid(row=0, column=1, sticky=E, pady=4)

Label(root, text='Last Name').grid(row=1, sticky=W, padx=4)
last_name = Entry(root).grid(row=1, column=1, sticky=E, pady=4)

#Button(root, text='Submit').grid(row=3)

getNameButton = Button(root, text='Get')
getNameButton.bind('&lt;Button-1&gt;', getName)
getNameButton.grid(row=3, column=1, sticky=E)


fieldEntry = Entry(root)
fieldEntry.grid(row=4, column=1, sticky=E)

root.mainloop()
</code></pre>