Reputation: 1344
I'm working with wxPython
and I'm trying to set the background colour of a specific item in UltimateListCtrl
. When I set the text for a specific item, like this:
list.SetItemText(1,"something")
This works without any problem. However, when I try the same with SetItemBackgroundColour
, for example, like this:
list.SetItemBackgroundColour(1,'#0000FF')
I get a strange error that I don't know how to fix:
Traceback (most recent call last):
File "C:\Program Files\DeVIDE-RE\python\lib\site-packages\wx-2.8-msw-unicode\w
x\lib\agw\ultimatelistctrl.py", line 6891, in OnPaint
enabled = theLine.GetItem(0, CreateListItem(line, 0)).IsEnabled()
File "C:\Program Files\DeVIDE-RE\python\lib\site-packages\wx-2.8-msw-unicode\w
x\lib\agw\ultimatelistctrl.py", line 4000, in GetItem
return item.GetItem(info)
File "C:\Program Files\DeVIDE-RE\python\lib\site-packages\wx-2.8-msw-unicode\w
x\lib\agw\ultimatelistctrl.py", line 3079, in GetItem
if self._attr.HasTextColour():
File "C:\Program Files\DeVIDE-RE\python\lib\site-packages\wx-2.8-msw-unicode\w
x\lib\agw\ultimatelistctrl.py", line 1183, in HasTextColour
return self._colText.Ok()
AttributeError: 'str' object has no attribute 'Ok'
Which is really strange because SetItemText
works fine. I checked the documentation but I could not understand why it's not working.
Any suggestions?
Upvotes: 0
Views: 157
Reputation: 5174
You need to pass a valid Color object in SetItemBackgroundColour instead of color string.
blue = Color(0, 0, 255)
list.SetItemBackgroundColour(1, blue)
Upvotes: 1