I’m trying to write a simple news feed reader in python.
I implemented a listview for the newspapers and a listview for the news of the selected newspaper
Now i’m trying to make the news listview colored but i’m find hard to do it.
I found some sample code that maybe can help here:
Making a colored BStringItem isn’t very difficult. The big thing is to subclass it and implement DrawItem(). You might be able to even get away with something like this:
This may or may not work, depending on the BStringItem implementation. Worst case you could grab a copy of BListItem.cpp from the source tree to look at how they did it.
class NewsItem(BListItem):
nocolor = (0, 0, 0, 0)
def init(self, name,color): self.name = name
self.color=color
BListItem.init(self)
def DrawItem(self, owner, frame, complete):
if complete:
owner.SetHighColor(self.nocolor)
owner.FillRect(frame)
owner.SetHighColor(self.color)
owner.MovePenTo(frame[0],frame[3])
owner.DrawString(self.name)
def Text(self):
return self.name
but now i have a little problem, when i select in the listview those colored items, they aren’t coloured as a normal selection(gray background), they have still the same background color (white) so i can’t understand what i have selected