1# Save data from entry widget to a text file:
2from tkinter import *
3
4def save_data():
5 name_info = name.get()
6
7 f = open("text_file.txt", "w")
8 f.write(name_info + "\n")
9 f.close()
10
11root = Tk()
12
13name = StringVar()
14
15Entry(root, textvariable=name).pack()
16
17Button(root, text='Save Data', command=lambda:save_data()).pack()
18
19root.mainloop()