python tkinter save entry data in txt file

Solutions on MaxInterview for python tkinter save entry data in txt file by the best coders in the world

showing results for - "python tkinter save entry data in txt file"
Giuseppe
20 Jan 2017
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()