'xalignd if not None, is a dict mapping col header to xalignent (default 1)
formatterd if not None, is a dict mapping col header to a ColumnFormatter'

def __init__(self, colheaders, formatterd=None):

    gtk.ScrolledWindow.__init__(self)
    self.colheaders = colheaders
    self.seq = None
    self.set_shadow_type(gtk.SHADOW_ETCHED_IN)
    self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    types = ([gobject.TYPE_STRING] * len(colheaders))
    model = self.model = gtk.ListStore(*types)
    treeview = gtk.TreeView(self.model)
    treeview.show()
    treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
    treeview.set_rules_hint(True)
    class Clicked:
        def __init__(self, parent, i):
            self.parent = parent
            self.i = i
            self.num = 0
        def __call__(self, column):
            ind = []
            dsu = []
            for (rownum, thisiter) in enumerate(self.parent.iters):
                val = model.get_value(thisiter, self.i)
                try:
                    val = float(val.strip().rstrip(u'%'))
                except ValueError:
                    pass
                if mlab.safe_isnan(val):
                    val = np.inf
                dsu.append((val, rownum))
            dsu.sort()
            if (not (self.num % 2)):
                dsu.reverse()
            (vals, otherind) = list(zip(*dsu))
            ind.extend(otherind)
            self.parent.model.reorder(ind)
            newiters = []
            for i in ind:
                newiters.append(self.parent.iters[i])
            self.parent.iters = newiters[:]
            for (i, thisiter) in enumerate(self.parent.iters):
                key = tuple([self.parent.model.get_value(thisiter, j) for j in range(len(colheaders))])
                self.parent.rownumd[i] = key
            self.num += 1
    if (formatterd is None):
        formatterd = dict()
    formatterd = formatterd.copy()
    for (i, header) in enumerate(colheaders):
        renderer = gtk.CellRendererText()
        if (header not in formatterd):
            formatterd[header] = ColumnFormatter()
        formatter = formatterd[header]
        column = gtk.TreeViewColumn(header, renderer, text=i)
        renderer.set_property(u'xalign', formatter.xalign)
        renderer.set_property(u'editable', True)
        renderer.connect(u'edited', self.position_edited, i)
        column.connect(u'clicked', Clicked(self, i))
        column.set_property(u'clickable', True)
        if (formatter.cell is not None):
            column.set_cell_data_func(renderer, formatter.cell)
        treeview.append_column(column)
    self.formatterd = formatterd
    self.lastcol = column
    self.add(treeview)
    self.treeview = treeview
    self.clear()
