[Tutor] _winreg problems enumerating
John.Gooch at echostar.com
Thu Apr 14 16:55:47 CEST 2005
Let me know if there is a Tkinter list that is more appropriate for this
I am writing a function whose job is it delete all of the selected items in
a Listbox. The only ways I can think of doing this is to
1) Get list of selected items using the listbox.curselection and then delete
each item one at a time.
2) Iterate through each item in the listbox and then call
listbox.delete(index) on each one that is selected.
The problem with each one is:
1) once the first item in the list of indexes is deleted, I think all of the
remaining items will "shift down" and their index number will change,
resulting in problem such as "index out of bounds", or deleting the wrong
2) Skip over a selected item if there are two selected items next to each
other. i.e. indexes 1 and 2 are selected, the for loop hits index 1 and
deletes it, the original "1" is gone and now the previous "2" becomes "1"(
shifts down ), the for loop continues on to index "2", failing to delete the
new index "1".
Is there an algorithm that can delete the selected items in one pass? Or
would I have to iterate over the listbox items until finally it does not
find any selected items.
John A. Gooch
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Englewood, CO 80112
More information about the Tutor