[wxPython-users] Moving items in a list
Robin Dunn
robin at alldunn.com
Mon Mar 10 12:50:52 PDT 2008
L. Fanchi wrote:
> Hello,
>
> I'm using an EditableListBox to display a list of images. I'd like to
> add the possibility of sorting an item in the list up or down.
> Now I bound the Up and Down buttons of the EditableListBox to OnUpItem
> and OnDownItem, respectively, but I'm not sure that the best way is to
> code the sorting. Changing the index won't work, I guess, since adding 1
> to the index of the currently selected item will overwrite the entry
> that is currently on 'selected item + 1'. I hope I described the problem
> clearly ;)
You can define the sort to use whatever order you want, since you pass
the comparison function that the sort will use. So you can define your
sort order to use something besides the index, perhaps the item's data
value. Then just change that value when you want to change the order,
and then resort the listctrl.
BTW, what is wrong with the default behavior of the move up and move
down buttons?
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list