Jump to content

how to clear entry and display into tkinter window widget

kee23

hey guys,

I have a python program that need some help with.

I have to somehow display a text from either from a txt file or from entry widget whenever the data is saved.

any help would be great.

from tkinter import *#this function will save the data from tkinter to .txt file.def save_data():    a = open("names.txt", "a")    a.write("%s\n" % name.get())    name.delete(0,END)#this will quit the widgetdef quitfunc():    app.destroy()    #this section will create GUI widget window containing lable, Entry and buttons here.app = Tk()app.title('Name Library')Label(app, text = "Please Enter Name Here:", fg="blue", height=3).pack()name = Entry(app)name.get()name.pack()Label(app, text="Current Name:  ", fg="blue").pack()Button(app, text = "Save", fg="red", command = save_data).pack()Button(app, text ="QUIT", fg="pink" , command=quitfunc).pack()#quitfunctionapp.configure(background="green")app.geometry('300x210+200+100')app.mainloop()
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×