title: Python Tkinter Entry get()
body: <p>I'm trying to use Tkinter's Entry widget.  I can't get it to do something very basic: return the entered value.<br>
  Does anyone have any idea why such a simple script would not return anything?  I've tried tons of combinations and looked at different ideas.<br>
  This script runs but does not print the entry:  </p>
  
  <pre><code>from Tkinter import *
  root = Tk()
  E1 = Entry(root)
  E1.pack()
  entry = E1.get()
  root.mainloop()
  print "Entered text:", entry
  </code></pre>
  
  <p>Seems so simple.</p>
  
  <p><strong>Edit:</strong>
  In case anyone else comes across this problem and doesn't understand, here is what ended up working for me.  I added a button to the entry window.  The button's command closes the window and does the get() function:  </p>
  
  <pre><code>from Tkinter import *
  def close_window():
      global entry
      entry = E.get()
      root.destroy()
  
  root = Tk()
  E = tk.Entry(root)
  E.pack(anchor = CENTER)
  B = Button(root, text = "OK", command = close_window)
  B.pack(anchor = S)
  root.mainloop()
  </code></pre>
  
  <p>And that returned the desired value.</p>