Open GoogleCodeExporter opened 8 years ago
I am using wxPython3.0-win32-py27 on a windows 7 machine.
Original comment by rob.cro...@gmail.com
on 15 Sep 2014 at 4:45
I realized that I could work around this by hacking together some string
formatting which grabs the decimal, floors the number, rjust to right align,
merge the round number back with the decimal and then insert into the listview.
Feels dirty:
def format_listitem(number,dec=1):
""" Accepts a number (either integer or floating point) and returns a formatted string for use in listviews """
rounded = int(math.floor(float(number)))
if dec == 1:
decimal = "{0:.1f}".format(float(number) - float(rounded))
elif dec == 2:
decimal = "{0:.2f}".format(float(number) - float(rounded))
formatted_string = "%s.%s" % (str(rounded).rjust(3), str(decimal))
formatted_string = formatted_string.replace(".0.",".")
return formatted_string
Original comment by rob.cro...@gmail.com
on 15 Sep 2014 at 5:44
However, rjust trickery can't fix sorting issues if the list contains positive
and negative numbers :(
Original comment by rob.cro...@gmail.com
on 15 Sep 2014 at 6:36
I figure that if I wasn't using gui2py I could set up a ColumnSorterMixin that
made use of something like this:
def natural_keys(text):
'''
alist.sort(key=natural_keys) sorts in human order
http://nedbatchelder.com/blog/200712/human_sorting.html
'''
return [ atoi(c) for c in re.split('([-]?\d+)', text) ]
Original comment by rob.cro...@gmail.com
on 15 Sep 2014 at 7:06
Original issue reported on code.google.com by
rob.cro...@gmail.com
on 15 Sep 2014 at 4:38Attachments: