Executing entry1=entry1.get()
before mainloop
will cause entry1
to have the value that is inside the Entry widget before the window appears. Since the user has had zero seconds to type anything in yet, that value will be the empty string. Delete that line.
Once you've deleted that line, printing entry
in the callback will give you a value like ".57381704L". That is the widget's unique identifier. If you want to get the text contents of the entry, print entry1.get()
instead.
You don't need the global statements. Those are only useful if you're reassigning the value of entry1
inside a function, which isn't necessary here.
from Tkinter import *
root = Tk()
def printentry1():
print entry1.get()
entry1 = Entry(root)
button = Button(root,text="Submit",command=printentry1)
entry1.pack()
button.pack()
root.mainloop()