{btn = QtGui.QPushButton('Button', self)
palettes = btn.palette()
palettes.setColor(btn.backgroundRole(),QtCore.Qt.green)
btn.setPalette(palettes)
btn.setAutoFillBackground(True)}
Using btn.backgroundRole() only provides green border to the button.
Using btn.foregroundRole() changes the text color of the button
Using btn.windowRole() gives me error
TypeError: arguments did not match any overloaded call:
QPalette.setColor(QPalette.ColorGroup, QPalette.ColorRole, QColor): argument 1 has unexpected type 'str'
QPalette.setColor(QPalette.ColorRole, QColor): argument 1 has unexpected type 'str'
Tried QtGui.QPalette.Background in place of btn.windowRole() but does nothing
Also tried QtGui.QPalette.Base but does nothing
And also QtGui.QPalette.Window does nothing
How can I change button color using palettes?
I am unable to rectify the problem. I am using windows 7, PyQt4 and Python 3.4