Python Tkinter GUI:add text from an entry widget in a pop up window to a listbox in a different window?
Question: I am trying to add an entry from a toplevel window into a listbox in the main
window. So far I have managed to create a button that opens a new window
containing 4 entry widgets(name, address, phone number and DOB). Is there any
way, after I press the OK button on the pop up window, that all four entries
are added to the listbox on the main window?

Thanks.


Answer: Unless I'm missing something in your problem description, the OK button
command just needs to copy the values from the Entry fields to the Listbox.
Was there more to it than that?

    
    
    from tkinter import Tk, Frame, Label, Entry, Button, Listbox
    
    def ok_button():
        li.delete(0, "end")
        for i in range(len(fields)):
            li.insert("end", e[i].get())
    
    root = Tk()
    root.title("Listbox")
    
    cf = Frame(root)
    cf.pack()
    fields = ("Name", "Address", "Phone", "DOB")
    e = []
    for f in fields:
        i = len(e)
        Label(cf, text=f).grid(column=2, row=i, sticky="e")
        e.append(Entry(cf, width=16))
        e[i].grid(column=4, row=i)
    Button(cf, text="OK", command=ok_button).grid(column=2, row=10, columnspan=3)
    li = Listbox(cf)
    li.grid(column=2, row=8, columnspan=3)
    
    root.mainloop()
    

