Formatting specific column in power table

Hello, I already have rows in power table that are with colors with this code :

	if selected:
		return {'background': self.selectionBackground}
	elif rowView % 2 == 0:
		return {'background': '237,239,243', 'foreground' : 'black' }
	else:
		return {'background': '176,183,196', 'foreground' : 'black' }

I would like to only paint the text in column 1 with red color using the same style above, I try this :

if colView == 1:
		return {'foreground' : 'red'}

but instead of painting just the text, and continuing to use the background color, the code has overwritten the style and kept the original background, is that a way to do this?

When you get into more complex configurations, your best bet is to use overrides.

attributes = {'foreground': 'black', 'background': '176,183,196'}

if colView == 1:
	attributes ['foreground'] = 'red'
	
if selected:
	attributes ['background'] = self.selectionBackground
elif rowView % 2 == 0:
	attributes ['background'] = '237,239,243'
	
return attributes 
1 Like

really thanks, works perfectly

1 Like