from tkinter import *

root = Tk()
root.title('tkinter Entry demo')
try:
    root.option_readfile('lecture_options.txt')
except TclError:
    pass

label = Label(root, text="occupation:")
label.grid(row=0, column=0, padx=5, pady=10)
stringVar = StringVar()
entry = Entry(root, width=40, textvariable=stringVar)
stringVar.set("What did you want to be?")
entry.grid(row=0, column=1, padx=5, pady=10)

# Note: Once mainloop exits, you can still retrieve the value of
# the textvariable ...
print('before the mainloop call, these two calls are equivalent:')
print('stringVar.get():', stringVar.get())
print('    entry.get():', entry.get())

root.mainloop()

print()
print('after the mainloop call, this still works:')
print('stringVar.get():', stringVar.get())
print('but this ...')
print('    entry.get():')
try:
    print(entry.get())
except:
    print('... raises an exception')
