I'm running Python 2.7 and I've got an ObjectListView
displaying loads of demographic info. I can get it to sort correctly, but the output is displayed in 100000.0
format. When I convert the integer to a string using the locale module, it sorts the descending strings like 9,181, 9,069, 818, 813, 8,730,
etc. Any ideas how to sort like integers, but display the output as comma formatted in the ObjectListView
?
Thanks for putting me on the right track! In the end I just ended up adding two lines to the ObjectListView.py source. Around line 3601, I changed the _StringToValue Function to include:
if converter == "%cd": ##New Line
return locale.format("%d", value, grouping=True) ##New Line
else:
fmt = converter or "%s"
try:
return fmt % value
except UnicodeError:
return unicode(fmt) % value
also needed to set locale after the local import, as show above:
locale.setlocale(locale.LC_ALL, 'en_US')
Thank you, I've been pounding my head on this one for a while now. Cheers!