list of Canvases contais only Nones
Laura Creighton
lac at strakt.com
Mon Jan 27 15:56:31 EST 2003
> hello,
>
> i am creating a frame with a lot of small canvases on it ant want to
> store the references in a list, but i get a list of nones instead.
> the frame gets created and shows all the canvases! so they are
> definitely somewhere.
>
> whats wrong with my code?
>
> #my try:
>
> canv_list = []
> root = Tkinter.Tk()
> for j in range(0,y_nr):
> for i in range(0,x_nr):
> canv_list.append(Tkinter.Canvas(root,
> width = x_size,
> height = y_size,
> background = 'white',
> border = 0
> ).grid(row=j,column=i)
> )
> print canv_list
>
> # the output of this code:
>
> [None, None, None, None, None, None]
>
> Thanks for help, Meinrad Recheis
>
> --
> http://mail.python.org/mailman/listinfo/python-list
<anything>.grid, and <anything>.pack return None. You need to make a
list of widget, row, col triplets, and then grid them all in a later
step.
Laura Creighton
More information about the Python-list
mailing list