Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80706

Re: help please: tkinter grid layout is very slow

From Terry Reedy <tjreedy@udel.edu>
Subject Re: help please: tkinter grid layout is very slow
Date 2014-11-13 17:14 -0500
References <91e0adb0-e4ef-4847-881a-7325e9a781d3@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.15790.1415916887.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 11/13/2014 3:45 PM, Rich Cook wrote:
> Hi, I'm trying to toss together an image browser in tkinter, and it is so slow it is unworkable.  Here is my code.  Can someone point out why it's so sloooow?  :-)  Thanks
>
> root = Tkinter.Tk()
> root.geometry("1000x280+300+300")
> label = Tkinter.Button(root, compound=Tkinter.TOP)
> label.pack()
>
> numimages = len(image_list)
> numcols = 6
> numrows = numimages/numcols

That should be numimages // numcols

> if numrows * numcols != numimages:
>      numrows += 1
>
> frame = Tkinter.Frame(root)
> for col in range(numcols):
>      frame.columnconfigure(col, pad=2)
>
> for row in range(numrows):
>      frame.rowconfigure(row, pad=2)
>
> 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(Image.open(image_list[imagenum]) )

ImageTk? or Tkinter?

>      b.grid(row=row, column = col)
>
> frame.pack()
>
> root.mainloop()
>


-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

help please:  tkinter grid layout is very slow Rich Cook <wealthychef@gmail.com> - 2014-11-13 12:45 -0800
  Re: help please:  tkinter grid layout is very slow Terry Reedy <tjreedy@udel.edu> - 2014-11-13 17:14 -0500
  Re: help please: tkinter grid layout is very slow Chris Angelico <rosuav@gmail.com> - 2014-11-14 10:39 +1100

csiph-web