Does the wxListCtrl wxColumnSorterMixin support sorting after list elements have been removed?

I get KeyError in wxColumnSorterMixin.__ColumnSorter() when trying to sort a column after on of the list element has been deleted.

Does the wxColumnSorterMixin support sorting after elements of the list have been removed (and renumbered)?

Do i have to repopulate the list and re-call some method?

Thanks for the help,

Pierre

Pierre Rouleau wrote:

I get KeyError in wxColumnSorterMixin.__ColumnSorter() when trying to sort a column after on of the list element has been deleted.

Does the wxColumnSorterMixin support sorting after elements of the list have been removed (and renumbered)?

Do i have to repopulate the list and re-call some method?

wxColumnSorterMixin expexts the data in itemDataMap to always accurately reflect what is in the listctrl.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Pierre Rouleau wrote:

I get KeyError in wxColumnSorterMixin.__ColumnSorter() when trying to sort a column after on of the list element has been deleted.

Does the wxColumnSorterMixin support sorting after elements of the list have been removed (and renumbered)?

Do i have to repopulate the list and re-call some method?

wxColumnSorterMixin expexts the data in itemDataMap to always accurately reflect what is in the listctrl.

That's what my code is doing. Obviously it must have a flaw somewhere. Is there an example where a listctrl (with column sorting) is used for editing a list (adding, removing) I could look to get more insight?

Thanks

Hi Pierre,

Pierre Rouleau wrote:

Robin Dunn wrote:

Pierre Rouleau wrote:

I get KeyError in wxColumnSorterMixin.__ColumnSorter() when trying to sort a column after on of the list element has been deleted.

Does the wxColumnSorterMixin support sorting after elements of the list have been removed (and renumbered)?

Do i have to repopulate the list and re-call some method?

wxColumnSorterMixin expexts the data in itemDataMap to always accurately reflect what is in the listctrl.

That's what my code is doing. Obviously it must have a flaw somewhere. Is there an example where a listctrl (with column sorting) is used for editing a list (adding, removing) I could look to get more insight?

Thanks

I use a listctrl with column sorter mixing, whenever the data changes (which comes from a db) I call PopulateList, however I moved a few calls for columnsorter mixing.

I.e. in listctrl.__init__ I do this

        wxColumnSorterMixin.__init__(self, len(self.colLabels))
        self.PopulateList()

and in listctrl.PopulateList I do this

        wxColumnSorterMixin.__init__(self, len(self.colLabels))
        self.currentItem = 0
        self.SortListItems(self.lcSortCol, self.lcSortOrd)

Note that mixin__init__ is called in both places, if I don't do this it doesn't work for me (will have to figure this out one day).

See you
Werner

···

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Hi Werner,

Werner F. Bruhin wrote:

Hi Pierre,

Pierre Rouleau wrote:

Robin Dunn wrote:

Pierre Rouleau wrote:

I get KeyError in wxColumnSorterMixin.__ColumnSorter() when trying to sort a column after on of the list element has been deleted.

Does the wxColumnSorterMixin support sorting after elements of the list have been removed (and renumbered)?

Do i have to repopulate the list and re-call some method?

wxColumnSorterMixin expexts the data in itemDataMap to always accurately reflect what is in the listctrl.

That's what my code is doing. Obviously it must have a flaw somewhere. Is there an example where a listctrl (with column sorting) is used for editing a list (adding, removing) I could look to get more insight?

Thanks

I use a listctrl with column sorter mixing, whenever the data changes (which comes from a db) I call PopulateList, however I moved a few calls for columnsorter mixing.

I.e. in listctrl.__init__ I do this

       wxColumnSorterMixin.__init__(self, len(self.colLabels))
       self.PopulateList()

and in listctrl.PopulateList I do this

       wxColumnSorterMixin.__init__(self, len(self.colLabels))
       self.currentItem = 0
       self.SortListItems(self.lcSortCol, self.lcSortOrd)

Note that mixin__init__ is called in both places, if I don't do this it doesn't work for me (will have to figure this out one day).

Thanks for your reply Werner and sorry to take that long to reply. I found out what i had to do to keep the sorter going in the presence of item deletion and insertion. The main thing seems to ensure that the self.itemDataMap always 'point' to the original dictionary. My original code was re-assigning a new dictionary whenever an item was deleted.

I just posted an updated version of the demo wxListCtrl.py (i call it wxListCtrl_1.py) that shows how the code is able to indert, delete items and there is only one call to the wxColumnSorterMixin.__init__().

Take a look at it, this may help you figure out why you had to call it twice.

Cheers,

Pierre

Pierre,

Pierre Rouleau wrote:

Hi Werner,

Werner F. Bruhin wrote:

Hi Pierre,

Pierre Rouleau wrote:

Robin Dunn wrote:

Pierre Rouleau wrote:

I get KeyError in wxColumnSorterMixin.__ColumnSorter() when trying to sort a column after on of the list element has been deleted.

Does the wxColumnSorterMixin support sorting after elements of the list have been removed (and renumbered)?

Do i have to repopulate the list and re-call some method?

wxColumnSorterMixin expexts the data in itemDataMap to always accurately reflect what is in the listctrl.

That's what my code is doing. Obviously it must have a flaw somewhere. Is there an example where a listctrl (with column sorting) is used for editing a list (adding, removing) I could look to get more insight?

Thanks

I use a listctrl with column sorter mixing, whenever the data changes (which comes from a db) I call PopulateList, however I moved a few calls for columnsorter mixing.

I.e. in listctrl.__init__ I do this

       wxColumnSorterMixin.__init__(self, len(self.colLabels))
       self.PopulateList()

and in listctrl.PopulateList I do this

       wxColumnSorterMixin.__init__(self, len(self.colLabels))
       self.currentItem = 0
       self.SortListItems(self.lcSortCol, self.lcSortOrd)

Note that mixin__init__ is called in both places, if I don't do this it doesn't work for me (will have to figure this out one day).

Thanks for your reply Werner and sorry to take that long to reply. I found out what i had to do to keep the sorter going in the presence of item deletion and insertion. The main thing seems to ensure that the self.itemDataMap always 'point' to the original dictionary. My original code was re-assigning a new dictionary whenever an item was deleted.

That was exactly my problem too.

···

I just posted an updated version of the demo wxListCtrl.py (i call it wxListCtrl_1.py) that shows how the code is able to indert, delete items and there is only one call to the wxColumnSorterMixin.__init__().

Take a look at it, this may help you figure out why you had to call it twice.

Cheers,

Pierre

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org