changing wx.mixins

"tjerk hoekstra" <[email protected]>
Newsgroups gmane.comp.python.pythoncard
Message-ID <000201c81e4f$3df51260$ee6ac00a@DCY7K3B1>
An irritating behaviour of MultiColumnList are that they seem to sort 
columns always like strings.  And if you put integers  in the MultiColumnList.items you get
errors so you have to change every thing to strings.(?)
So when you have a column with 'numbers' like  88,125,9,2
and click on the ColumnHeader it sorts thus  9,88,2,125
wich is mostly useless.
So now I changed some lines in the mixins from wx.
If anybody also wants a different sort behaviour do this.
In wx.lib.mixins.lstctrl change this lines in 
__ColumnSorter(self,key1,key2):
    col = self._col
        ascending = self._colSortFlag[col]
        item1 = self.itemDataMap[key1][col]
        item2 = self.itemDataMap[key2][col]

        #--- Internationalization of string sorting with locale module
        if type(item1) == type('') or type(item2) == type(''):
            cmpVal = locale.strcoll(str(item1), str(item2))
        else:
            cmpVal = cmp(item1, item2)

lines added underlined

    col = self._col
        ascending = self._colSortFlag[col]
        item1 = self.itemDataMap[key1][col]
        item2 = self.itemDataMap[key2][col]

        #--- Internationalization of string sorting with locale module
        if type(item1) == type('') or type(item2) == type(''):
            if item1.isdigit() and item2.isdigit():
                cmpVal=cmp(float(item1),float(item2))
            else:
                cmpVal = locale.strcoll(str(item1), str(item2))
        else:
            cmpVal = cmp(item1, item2)
       

So now the MultiColumnList recognizes numbers in the column, and sort according 
to value...so  88,125,9,2  turns into 125,88,9,2


Any comments?
Tjerk Hoekstra
Castro Brazil

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
Pythoncard-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pythoncard-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.