Get()

Ramsey Nasser aladameh at gmail.com
Sat Dec 15 14:19:39 EST 2007


The grid method of these widgets returns None. When you say something like:

ent = Entry(root, fg = '#3a3a3a', bg = 'white', relief =
'groove').grid(row = 0, padx = 3, pady = 3)

You're actually assigning the value of the last method on the right
hand side (in this case, grid) to the variable on the left hand side
(in this case ent). Since grid returns None, ent is set to None, and
the insert function fails.

What you want to do is replace your GUI initialization code with
something like this:

ent = Entry(root, fg = '#3a3a3a', bg = 'white', relief = 'groove')
ent.grid(row = 0, padx = 3, pady = 3)

button = Button(root, text = "Remember", command = insert, relief =
'groove', fg = '#3a3a3a')
button.grid(row = 0, column = 1, padx = 3, pady = 3)

box = Listbox(root, bg = '#ebe9ed', relief = 'groove')
box.grid(row = 2, columnspan = 2, sticky = W+E, padx = 3)

This way ent, button and box get set to their respective widgets, the
grid method does its thing and the insert function works as expected.

-- 
nasser



More information about the Python-list mailing list