ObjectListView - how to programmatically check or uncheck items

Hi,

I realized I need a way to programmatically check and uncheck all the items in my ObjectListView widget. I found a ToggleCheck method, but it doesn’t appear to work. Basically, I created a button handler with the following code in it:

objects = self.resultsOlv.GetObjects()
for obj in objects:
self.resultsOlv.ToggleCheck(obj)

But that doesn’t actually do anything to the UI. Does anyone know how to do a “check all” or “uncheck all” function for this? I can’t find a method in the Item object for that either. I’m on Windows with Python 2.6 and wxPython 2.8.12

Thanks,
Mike

After some more digging, I finally noticed that ToggleCheck was doing the job, but it wasn’t updating the display. The same is true with the SetCheckState() method. I think it is also doing what it’s supposed to, but not updating the display. To get this to work, you need to do something like this:

objects = self.resultsOlv.GetObjects()
for obj in objects:
print self.resultsOlv.IsChecked(obj)
self.resultsOlv.ToggleCheck(obj)
self.resultsOlv.RefreshObjects(objects)

That worked for me anyway. Sorry for the noise.

  • Mike