Problem with ListCtrl and making items flash

I need a way of displaying many rows of data with multiple columns where I can
select the colour and also make certain rows flash. I've acheived this by
using a ListCtrl with style=wx.LC_REPORT|wx.LC_VIRTUAL.

I then have a loop created using:

        self.refresh_loop = wx.FutureCall(500, self.refresh_items)

I have an instance variable which hods the current flash state (on or off) and
self.refresh_items basicaly toggles tis state each tie, checks if any of the
rows have changed, and if any need to be flashing.

If no rows have changed and none are flashing, self.refresh_loop.Restart is
called.

Otherwise I sort the data, then do the following:

        self.SetItemCount(0)
        self.SetItemCount(len(self.items_to_display))
        self.RefreshItems(0, len(self.items_to_display))

The flashing is then acheived in the OnGetItemAttr method which automatically
gets called due to the "virtualness" and if the item should be flashing and
the flash state is on, it sends the colour, if it should be flashing and flash
state is off, it sends the background colour.

This works great, apart from a bit of flickering, when I have no items
flashing and when I've got items flasing but not too many to be displayed.
When I have items flashing and there are too many to be displayed and
therefore requiring scrollbars, problems begin. I can move the scrollbar, but
next refresh (500ms later maximum) it resets back to the top and then all the
GUI becomes non-responsive pretty much all the time.

I need to beable to have a list of rows, some which could be flashing, that I
can update continuously and I can scroll through even while the list is
updating.

I think the problem lies with me setting the item count to zero, but I need to
do this otherwise when some items get added, or removed it doesn't add/remove
them properly unless i clear the items then re-display them.

Any help would be greatly appreciated!!

Many Thanks
Craig

Craig Douglas <craig.douglas <at> rtkinstruments.com> writes:

Otherwise I sort the data, then do the following:

        self.SetItemCount(0)
        self.SetItemCount(len(self.items_to_display))
        self.RefreshItems(0, len(self.items_to_display))

I think the problem lies with me setting the item count to zero, but I need

to

do this otherwise when some items get added, or removed it doesn't

add/remove

them properly unless i clear the items then re-display them.

Thought i'd just exlain the solution.

The problem was, as expected, in setting the item count to zero. My
RefreshItems line should have been:
        self.RefreshItems(0, len(self.items_to_display)-1)
Which now works correctly.