Q:

How can I update entry widget entries in a toplevel window in tkinter?

what I want to do, is to open from the root window a toplevel window in which I have series of entry widgets, modify the entries and close the window. I found a code in one of the posts and modified it to fit my need. The code works only the first time I open the toplevel window, but after that it opens the toplevel window without the entry fields! I don't understand what is happening!! Can anyone help please? I am quite new to python. Here is the code:
from tkinter import *
root = Tk()
entry_list = []
def openwindow():
    window = Toplevel()
    window.title("Data")
    entry_list.clear()

    for i in range(10):
        entry_list.append(Entry(window))
        entry_list[i].grid()

    def update_entry_fields():
        for i in entry_list:
            i.delete(END)
            i.insert(0, "")
        print(float(entry_list[0].get()))

    def closewindow():
        window.withdraw()

    savebtn = Button(window, text="Save & print", command = update_entry_fields)
    closebtn = Button(window, text="Close", command=closewindow)
    savebtn.grid()
    closebtn.grid()

def printout():
    print(float(entry_list[0].get()))

printbtn = Button(root, text="Test print", command = printout)
printbtn.grid()
openbutton = Button(root, text="open data sheet", command=openwindow)
openbutton.grid()

root.mainloop()

A:

Here is the solution that at least i was looking for.  
from tkinter import *
root = Tk()
entry_list = []
p = [5, 6, 7, 8, 9]
def openwindow():
    window = Toplevel()
    window.title("Data")
    entry_list.clear()

    for i in range(5):
        v = DoubleVar()
        entry_list.append(Entry(window, textvariable=v))
        entry_list[i].grid()
        v.set(p[i])   # set default entry values

    def update_entry_fields():
        for i in range(5):
            p[i]=entry_list[i].get()   # overwrite the entry
            # test print from inside
            print(p[i])
            window.withdraw()

    savebtn = Button(window, text="Save & close", command = update_entry_fields)
    savebtn.grid()
    window.mainloop()
# Test print from outside of function
def printout():
    print(p[0])

printbtn = Button(root, text="Test print", command = printout)
printbtn.grid()
openbutton = Button(root, text="open data sheet", command=openwindow)
openbutton.grid()
#
root.mainloop()

