To the best of my knowledge, the only way to do this is as you describe: delete
the old item, then insert the new item.  The Tk manpage for "listbox" doesn't
describe any commands to only update an item in the list.

Actually, you may have another choice, if your Tk is new enough---Tk supports
(in 8.4, and maybe 8.3) the -listvariable configuration option on listboxes.

.>>> t = Tkinter.Tk()
.>>> v = Tkinter.Variable(t)
.>>> l = Tkinter.Listbox(t, listvariable=v); l.pack()
.>>> v.set((1,2,3))

Now, if you assemble a Python sequence 's', you can set the list's contents
to that sequence with
.>>> v.set(tuple(s))
this still doesn-t allow slice-like updating of listboxes, however.

Finally, you could subclass the Tkinter.Listbox, and replace the __setitem__
and __setslice__ methods with methods that manipulate the underlying listbox
in the appropriate ways, then create these objects instead of Tkinter.Listbox.
I'll leave that as an exercise for the reader.  Feel free to contribute the code
to the Tkinter wiki (http://tkinter.unpy.net).

Jeff

Attachment: pgpWzm7qAW52n.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to