Colored BListView/BListItem/BStringItem

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:

but it’s in C++
and i’m not sure how to implement it in python

is there some easy way to make a BStringItem colored? or can someone help me translate that class to python?

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:

ColoredStringItem::DrawItem(BView *owner, BRect frame, bool complete) { owner->SetLowColor(128,128,255); owner->SetHighColor(0,0,0); BStringItem::DrawItem(owner, frame, false); }

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.

Thank you! :slight_smile:

I created this BListItem Class:

class NewsItem(BListItem):
nocolor = (0, 0, 0, 0)
def init(self, name,color): = name
def DrawItem(self, owner, frame, complete):
if complete:

def Text(self):

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