Tkinter itemconfigure and memory leaks

Angelo B abonet at yahoo.com
Wed Apr 23 20:51:59 EDT 2003


The itemconfigure() method of Listbox seems to create a memory leak in
the following use case.  Comment out the call to itemconfigure() and
the memory leak disappears.  I'm running Python 2.2 (I think you need
at least 2.2 for the itemconfigure method to even be present on
Listbox).  I've seen the leak on both Compaq Tru64 5.1A and SunOS 5.6.

Is this a genuine bug?  Or is there some technique that I don't know
about to prevent this (i.e. a different way of coloring items in a
Lisbox)?

Any help or insight is appreciated.


import Tkinter as Tk
Lb = None

def update_lb ():
    global Lb    
    Lb.delete(0, Tk.END)

    for ii in range(100):
	Lb.insert(Tk.END, 'Item %d' % ii)
	Lb.itemconfigure(ii, bg='red')

    Lb.after(10, update_lb)


root = Tk.Tk()
Lb = Tk.Listbox(root)
Lb.pack()
Lb.after(1000, update_lb)
root.mainloop()




More information about the Python-list mailing list