I've set up a gtk.TreeView
with a gtk.TreeStore
. One column contains formatted dollar amounts, and I've set up sorting by that column as follows:
def sortmon(model, i1, i2):
v1 = model[i1][COL_MONEY]
v2 = model[i2][COL_MONEY]
return cmp(float(v1.replace("$","").replace(",","")),
float(v2.replace("$","").replace(",","")))
self.hsModel.set_sort_func(COL_MONEY, sortmon)
This works fine, except that sometimes, when I append a row, I get:
stderr : INFO Traceback (most recent call last):
stderr : INFO File "C:\Users\DrClaud\bumhunter\gui\widgets\replay\ReplayWidget.py", line 141, in sortpot
stderr : INFO float(v2.replace("$","").replace(",","")))
stderr : INFO AttributeError: 'NoneType' object has no attribute 'replace'
I did more print outs, and it seems that when I insert a row, one of model[i1][x]
or model[i2][x]
for any x will be None. I'm certain I'm not inserting a row with None
elements in it.. so what happens?