am adding a GUI into a python database and i was wondering if there is any way for text to be already in an entry box when it appears. The window is for adding movies to the database so i would like the following, please enter the movies title: [Title ], with [] being my entry box.

def addmovie():
addboard = Tkinter.Toplevel()
addboard.title("Add a movie")
addboard.geometry("600x600")
#addboard(padx=10, pady=10)
print "add"
#adding the title

lbtitle = Tkinter.Label(addboard, text = "Enter the movie's title:")
lbtitle.grid(row = 1, column = 1)
entitle = Tkinter.Entry(addboard)
entitle.grid(row = 1, column = 3)
#adding the director
lbdirector = Tkinter.Label(addboard, text = "Enter the mmovie's director:")
lbdirector.grid(row = 2, column = 1)
endirector = Tkinter.Entry(addboard)
endirector.grid(row = 2, column = 3)
#adding the year
lbyear = Tkinter.Label(addboard, text = "Enter the movie's year:")
lbyear.grid(row = 3, column = 1)
enyear = Tkinter.Entry(addboard)
enyear.grid(row = 3, column = 3)
#if a value is left blank program will ask what to do
#to be added later

#The button and the commands to put it all together
btnok = Tkinter.Button(addboard, text = "Continue", bg = 'red', command = addcontinue)
btnok.grid(row= 5, column = 4)
btncancel = Tkinter.Button(addboard, text = "Cancel", bg= 'red', command=addboard.destroy)
btncancel.grid(row = 5, column = 1)

def addcontinue():
id = len(movie_list) + 1
id_list.append(id)
title = entitle.get()
director = endirector.get()
year = enyear.get()
movie_list.append(Movie(title, director, year, id))

also i am having trouble with recalling the entry text after the continue button is pressed. What is the correct way to move the entered text from the entries into the next section where it will be processed?

Recommended Answers

All 4 Replies

You have at least problem with indentation.

Take a look at Effbot's tutorial for an entry box to find out how you set and get the text as there are at least two ways to do it.

haha i copy and pasted my code from an ide it didnt copy my indentation. thanks for pointing me to the page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.