Im using the current List Widget and I would like to know how to set a color per row and a specific TOP per cell.
More concrete:
In my List I have a cell per row called ‘Active’ and in the cell is either a 0 or a 1. I would like to have the rows with ‘Active’ = 0 have a red background color. Additionally instead of having 0 and 1 displayed I would like to choose a TOP accordingly → Happy Smiley, Not Happy Smiley.
Im checking inside the List colDefine on the wiki but somehow I cant get it off the ground. Any pointers?
Attached is a excerpt of my list showing whats happening. customlist.tox (38.4 KB)
To set a specific color depending on data, you have to use callbacks and there are multiple ways. I recommend this: set the column’s “sourceDataMode” to “color”. Then, in the onConvertData callback, do something like this:
def onConvertData(info):
for row in info['data']:
colorCol = 3
if row[colorCol] == '0':
row[colorCol] = [0,0,0,255]
else:
row[colorCol] = [255,0,0,255]
This makes it so whenever the list’s data is refreshed, the column’s 1 or 0 is converted to a color.