help please: tkinter grid layout is very slow

Chris Angelico rosuav at
Fri Nov 14 00:39:08 CET 2014

On Fri, Nov 14, 2014 at 7:45 AM, Rich Cook <wealthychef at> wrote:
> print "There are", numimages, "images"  # 256 in fact...
> for imagenum, (row, col) in enumerate([(row,col) for row in range(numrows) for col in range(numcols)]):
>     b = Tkinter.Label(frame, compound = Tkinter.TOP)
>     b['text'] = os.path.basename(image_list[imagenum])
>     b['image'] = ImageTk.PhotoImage([imagenum]) )

You're asking someone somewhere to load 256 images into memory and
display them. What's the resolution of these images? Do they need to
be scaled/cropped? That can be fairly expensive. How long does it
actually take to (a) load all those images, and (b) pack the frame?
Try, for instance, commenting out the b.grid() call, to force them all
to be loaded but not packed.


More information about the Python-list mailing list