Search code examples
pythonwxpythonobjectlistview-python

remove alternating colors in ObjectListView


I need help removing the alternating colors from my ObjectListView.

    self.problist = ObjectListView(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
    self.problist.SetColumns([
            ColumnDefn("Problem", "left", 400, valueGetter="short_des"),
            ColumnDefn("First Treated", "left", 100, valueGetter="prob_date"),
            ColumnDefn("ICD-10 Code", "left", 100, valueGetter="icd10")
            ])
    self.problist.SetObjects(problems)
    self.problist.cellEditMode = ObjectListView.CELLEDIT_DOUBLECLICK
    self.problist.Bind(EVT_CELL_EDIT_STARTING, self.HandleCellEditStarting)
    self.problist.Bind(EVT_CELL_EDIT_FINISHED, self.HandleCellEditFinished)
    self.problist.rowFormatter = self.rowFormatter
    self.problist.useAlternateBackColors = False

I've also tried self.problist.useAlternateBackColors(False). This is set automatically to True. After searching through the documentation I haven't found any indications about how one sets this ObjectListView property.

Thanks


Solution

  • You need to set this before loading the objects.

        self.problist = ObjectListView(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
            self.problist.SetColumns([
                    ColumnDefn("Problem", "left", 400, valueGetter="short_des"),
                    ColumnDefn("First Treated", "left", 100, valueGetter="prob_date"),
                    ColumnDefn("ICD-10 Code", "left", 100, valueGetter="icd10")
                    ])
            self.problist.useAlternateBackColors = False
            self.problist.SetObjects(problems)
            self.problist.cellEditMode = ObjectListView.CELLEDIT_DOUBLECLICK
            self.problist.Bind(EVT_CELL_EDIT_STARTING,   self.HandleCellEditStarting)
            self.problist.Bind(EVT_CELL_EDIT_FINISHED, self.HandleCellEditFinished)
            self.problist.rowFormatter = self.rowFormatter