1 pythonCopyimport tkinter as tk
2root = tk.Tk()
3root.geometry("400x50")
4
5def setTextInput(text):
6 textExample.delete(0,"end")
7 textExample.insert(0, text)
8
9textExample = tk.Entry(root)
10textExample.pack()
11
12btnSet = tk.Button(root, height=1, width=10, text="Set",
13 command=lambda:setTextInput("new content"))
14btnSet.pack()
15
16root.mainloop()