本文整理匯總了Python中PyQt4.Qt.QPalette.color方法的典型用法代碼示例。如果您正苦於以下問題:Python QPalette.color方法的具體用法?Python QPalette.color怎麽用?Python QPalette.color使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.Qt.QPalette
的用法示例。
在下文中一共展示了QPalette.color方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_color
# 需要導入模塊: from PyQt4.Qt import QPalette [as 別名]
# 或者: from PyQt4.Qt.QPalette import color [as 別名]
def set_color(self):
r, g, b = gprefs['cover_grid_color']
pal = QPalette()
col = QColor(r, g, b)
pal.setColor(pal.Base, col)
dark = (r + g + b)/3.0 < 128
pal.setColor(pal.Text, QColor(Qt.white if dark else Qt.black))
self.setPalette(pal)
self.delegate.highlight_color = pal.color(pal.Text)
示例2: set_color
# 需要導入模塊: from PyQt4.Qt import QPalette [as 別名]
# 或者: from PyQt4.Qt.QPalette import color [as 別名]
def set_color(self):
r, g, b = gprefs['cover_grid_color']
pal = QPalette()
col = QColor(r, g, b)
pal.setColor(pal.Base, col)
tex = gprefs['cover_grid_texture']
if tex:
from calibre.gui2.preferences.texture_chooser import texture_path
path = texture_path(tex)
if path:
pal.setBrush(pal.Base, QBrush(QPixmap(path)))
dark = (r + g + b)/3.0 < 128
pal.setColor(pal.Text, QColor(Qt.white if dark else Qt.black))
self.setPalette(pal)
self.delegate.highlight_color = pal.color(pal.Text)
示例3: set_color
# 需要導入模塊: from PyQt4.Qt import QPalette [as 別名]
# 或者: from PyQt4.Qt.QPalette import color [as 別名]
def set_color(self):
r, g, b = gprefs['cover_grid_color']
pal = QPalette()
col = QColor(r, g, b)
pal.setColor(pal.Base, col)
tex = gprefs['cover_grid_texture']
if tex:
from calibre.gui2.preferences.texture_chooser import texture_path
path = texture_path(tex)
if path:
pm = QPixmap(path)
if not pm.isNull():
val = pm.scaled(1, 1).toImage().pixel(0, 0)
r, g, b = qRed(val), qGreen(val), qBlue(val)
pal.setBrush(pal.Base, QBrush(pm))
dark = (r + g + b)/3.0 < 128
pal.setColor(pal.Text, QColor(Qt.white if dark else Qt.black))
self.setPalette(pal)
self.delegate.highlight_color = pal.color(pal.Text)