我如何在 PyQt/PySide 应用程序中查询这些值,而不是“手动”定义列表groups
和(在下面的代码中)?roles
from PyQt4 import QtGui
groups = ['Disabled', 'Active', 'Inactive', 'Normal']
roles = [
'AlternateBase',
'Background',
'Base',
'Button',
'ButtonText',
'BrightText',
'Dark',
'Foreground',
'Highlight',
'HighlightedText',
'Light',
'Link',
'LinkVisited',
'Mid',
'Midlight',
'Shadow',
'ToolTipBase',
'ToolTipText',
'Text',
'Window',
'WindowText'
]
def getPaletteInfo():
palette = QtGui.QApplication.palette()
#build a dict with all the colors
result = {}
for role in roles:
print role
for group in groups:
qGrp = getattr(QtGui.QPalette, group)
qRl = getattr(QtGui.QPalette, role)
result['%s:%s' % (role, group)] = palette.color(qGrp, qRl).rgba()
return result