Python How to copy value from an Entry field to a Text field in Tkinter
Question: I’m trying to make a simple GUI with Tkinker that when you press a button it
adds the value in the Entry field to the next row in the Text field.

    
    
    from tkinter import *
    
    #def onclick():
    #   pass
    
    class MyApp:
        def __init__(self):
            window=Tk()
            window.title('Multi Line Text Form')
            frame = Frame(window)
            frame.pack()
            #self.fields ={}
    
            l = Label(frame, text="Text to add below: ")
            l.grid(row=0, column = 0)
            #self.fields['name'] = Entry(frame)
            name = Entry(frame)
            #self.fields['name'].grid(row=0,column=1)
            name.grid(row=0,column=1)
    
            self.text = Text(frame, width=40, height=10)
            self.text.grid(row=3,column=1)
            self.text.insert(INSERT, "Hello.....")
            self.text.insert(END, "Bye Bye.....")
    
            msg = name.get()
    
            updatebtn = Button(frame, text="Update Text Box", command=self.writeToLog(name))
            updatebtn.grid(row=0, column=2)
    
            window.mainloop()
    
    
        def writeToLog(self, msg):
            print(msg)
            numlines = self.text.index('end - 1 line').split('.')[0]
            #text['state'] = 'normal'
            if numlines==4:
                self.text.delete(1.0, 2.0)
            if self.text.index('end-1c')!='1.0':
                self.text.insert('end', '\n')
            self.text.insert('end', msg)
            #text['state'] = 'disabled'
    
    
    if __name__=="__main__":
        MyApp()
    


Answer: Your button needs to be configured with the _name_ of a function to call. This
function can then get the value from the entry widget and put it in the text
widget:

    
    
    def __init__(self):
        ...
       updatebtn = Button(command=self.update_text)
       ...
       self.name_entry = Entry(frame)
    
    def update_text(self):
        data = self.name_entry.get()
        self.writeToLog(data)
    

