On Jan 7, 2008, at 2:06 PM, Cam Farnell wrote: > 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
Cam - this next line is probably the culprit. Calling forget doesn't delete the instance of the control, so when you create the new Labels below, you're building a huge stack of controls. I'd recommend simply updating the label text so that you reuse the existing controls. > 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. HTH, Tim _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss