Quoting "Gooch, John" <[EMAIL PROTECTED]>:

> I am writing a function whose job is it delete all of the selected items
> in a Listbox.

I think this problem is the same as the general problem of deleting a selection
of items from a python list.  The general solution is to iterate through the
list of selected indices backwards.

eg:

>>> from Tkinter import *
>>> tk = Tk()
>>> lb = Listbox(tk, selectmode=EXTENDED)
>>> lb.pack()
>>> for i in range(10):  # Inserting integers, so initially the item in each
...  lb.insert(END, i)   # position will be the same as its index.
... 
>>> lb.curselection()
('2', '4', '5', '7')
>>> for i in lb.curselection()[-1::-1]:
...  lb.delete(i)
... 
>>> lb.get(0, END)
(0, 1, 3, 6, 8, 9)
>>> 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to