def _set_color(widget, role, color): pal = widget.palette() pal.setColor(role, QColor(color)) widget.setAutoFillBackground(True) widget.setPalette(pal) widget.update()