[Tkinter-discuss] Tkinter slows down

Cam Farnell hsa01 at bitflipper.ca
Mon Jan 7 22:06:12 CET 2008


I'm creating a program which displays spreadsheet-like data using 
hundreds of labels. At first this works fine, however after a few 
redisplays it starts slowing down dramatically.

A small test program, without the distractions of the real program is:

from Tkinter import *
def Go():
     LabelList = []
     for J in range(30):
         print J
         for L in LabelList: L.grid_forget()
         LabelList = []
         for Row in range(20):
             for Col in range(20):
                 L = Label(r,text='%s'%J)
                 L.grid(row=Row,column=Col)
                 LabelList.append(L)
         r.update_idletasks()
r = Tk()
r.after(1000,Go)
r.geometry('800x600')
r.mainloop()

This runs quickly at first but gradually slows down to a crawl during 
the latter iterations. Anyone have any idea what is causing this to go 
slow or how I could speed it up? I'm running Python 2.4.3 on an Ubuntu 
6.06 system.

Thanks

Cam Farnell


More information about the Tkinter-discuss mailing list