Tkinker Python Tutorial

from Tkinter  import *
root = None
namentry = None
addressentry = None
name = None
address = None
def close_window() :
    global name
    global address
    global nameentry, addressentry
    name = nameentry.get()
    address = addressentry.get()
    root.destroy()
def DoInputForm(root):
    global nameentry, addressentry
    Label(root, text="Enter name:").grid(row=0, sticky=W)
    Label(root, text="Enter address:").grid(row=1, sticky=W)
    nameentry = Entry(root)
    addressentry = Entry(root)
    nameentry.grid(row=0, column=1)
    addressentry.grid(row=1, column=1)
    Button(root, text="Ok", command=close_window).grid(row=2, column=0)
    Button(root, text="Cancel", command=close_window).grid(row=2, column=1)
root = Tk()
DoInputForm(root)
root.mainloop()
print "Name: "+name
print "Address:"+ address