本文整理汇总了Python中PySide.QtGui.QColor.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.setAlpha方法的具体用法?Python QColor.setAlpha怎么用?Python QColor.setAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.setAlpha方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromStr
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def fromStr(name, a=255):
if name in _Colorizer.__colorTable:
c = QColor(_Colorizer.__colorTable[name])
else:
c = QColor(Qt.transparent)
c.setAlpha(a)
return c
示例2: _init_ui
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def _init_ui(self, txt):
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)
pal = QPalette()
color = QColor()
color.setNamedColor(self._window_bgcolor)
color.setAlpha(255 * self._opacity)
pal.setColor(QPalette.Background, color)
self.setAutoFillBackground(True)
self.setPalette(pal)
wm, hm = 5, 5
spacing = 8
layout = QVBoxLayout()
layout.setSpacing(spacing)
layout.setContentsMargins(wm, hm, wm, hm)
nlines, ts = self._generate_text(txt)
qlabel = QLabel('\n'.join(ts))
ss = 'QLabel {{color: {}; font-family:{}, sans-serif; font-size: {}px}}'.format(self._color,
self._font,
self._fontsize)
qlabel.setStyleSheet(ss)
layout.addWidget(qlabel)
hlabel = QLabel('double click to dismiss')
hlabel.setStyleSheet('QLabel {font-size: 10px}')
hlayout = QHBoxLayout()
hlayout.addStretch()
hlayout.addWidget(hlabel)
hlayout.addStretch()
layout.addLayout(hlayout)
self.setLayout(layout)
font = QFont(self._font, self._fontsize)
fm = QFontMetrics(font)
pw = max([fm.width(ti) for ti in ts])
ph = (fm.height() + 2) * nlines
w = pw + wm * 2
h = ph + (hm + spacing + 1) * 2
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.setFixedWidth(w)
self.setFixedHeight(h)
self.setMask(mask(self.rect(), 10))
示例3: routeFinished
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def routeFinished(self):
if not self.routeReply.routes():
return
route = QGeoMapRouteObject(self.routeReply.routes()[0])
routeColor = QColor(Qt.blue)
routeColor.setAlpha(127)
pen = QPen(routeColor)
pen.setWidth(7)
pen.setCosmetic(True)
pen.setCapStyle(Qt.RoundCap)
route.setPen(pen)
self.mapWidget.addMapObject(route)
示例4: drawPolygon
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def drawPolygon(self):
path = [mark.coordinate() for mark in self.markerObjects]
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
polygon = QGeoMapPolygonObject()
polygon.setPen(pen)
fill = QColor(Qt.black)
fill.setAlpha(65)
polygon.setBrush(QBrush(fill))
polygon.setPath(path)
self.mapWidget.addMapObject(polygon)
示例5: drawRect
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def drawRect(self):
if len(self.markerObjects) < 2:
return
p1, p2 = self.markerObjects[:2]
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
fill = QColor(Qt.black)
fill.setAlpha(65)
rectangle = QGeoMapRectangleObject(p1.coordinate(), p2.coordinate())
rectangle.setPen(pen)
rectangle.setBrush(QBrush(fill))
self.mapWidget.addMapObject(rectangle)
示例6: WeekCalendar
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
class WeekCalendar(QCalendarWidget):
def __init__(self, *args):
QCalendarWidget.__init__(self, *args)
self.color = QColor(self.palette().color(QPalette.Highlight))
self.color.setAlpha(64)
self.selectionChanged.connect(self.updateCells)
def paintCell(self, painter, rect, date):
QCalendarWidget.paintCell(self, painter, rect, date)
filelist = glob.glob('journal_[0-9]*')
datelist = []
for i in filelist:
l = tuple(i[i.index('_') + 1:].split('_'))
datelist.append(QDate(int(l[2]), int(l[1]), int(l[0])))
if date in datelist:
painter.fillRect(rect, self.color)
示例7: createPixmapIcon
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def createPixmapIcon(self):
self.markerIcon = QPixmap(MARKER_WIDTH, MARKER_HEIGHT)
self.markerIcon.fill(Qt.transparent)
painter = QPainter(self.markerIcon)
p1 = QPoint(MARKER_WIDTH / 2, MARKER_HEIGHT - 1)
p2 = QPoint(MARKER_WIDTH / 2, MARKER_HEIGHT - 1 - MARKER_PIN_LEN)
pen = QPen(Qt.black)
pen.setWidth(2)
pen.setCosmetic(True)
painter.setPen(pen)
painter.drawLine(p1, p2)
ellipse = QRect(0, 0, MARKER_WIDTH - 1, MARKER_HEIGHT - 1)
pen.setWidth(1)
painter.setPen(pen)
color = QColor(Qt.green)
color.setAlpha(127)
brush = QBrush(color)
painter.setBrush(brush)
painter.drawEllipse(ellipse)
示例8: drawCircle
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def drawCircle(self):
if not len(self.markerObjects):
return
p1 = self.markerObjects[0]
center = p1.coordinate()
radius = 3000 # Meters
if len(self.markerObjects) >= 2:
radius = center.distanceTo(self.markerObjects[1].coordinate())
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
circle = QGeoMapCircleObject(center, radius)
circle.setPen(pen)
fill = QColor(Qt.black)
fill.setAlpha(65)
circle.setBrush(QBrush(fill))
self.mapWidget.addMapObject(circle)
示例9: fromQcolor
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def fromQcolor(qtColor, a=255):
c = QColor(qtColor)
c.setAlpha(a)
return c
示例10: QcolorA
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def QcolorA(color, alpha):
col = QColor(color)
col.setAlpha(alpha)
return col
示例11: _display_color
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def _display_color(color, selected):
alpha = 0.7 if selected else 0.4
color = QColor(color)
color.setAlpha(255 * alpha) # Set alpha to half for display
return color
示例12: QColor
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
from PySide.QtGui import QColor, QBrush, QPen
from PySide.QtCore import Qt
print "Initializing Color"
colorHexLine = QColor(Qt.green)
colorHexBrush = QColor(192,255,192)
colorHexRoute = QColor(255,192,0)
colorHexRoute.setAlpha(128)
colorHexRouteSel = QColor(192,128,0)
colorHexRouteSel.setAlpha(128)
penLine = QPen(colorHexLine)
penLine.setWidthF(2.0)
penRoute = QPen(colorHexRoute)
penRoute.setWidthF(12.0)
penRouteSel = QPen(colorHexRouteSel)
penRouteSel.setWidthF(12.0)
brushHex = QBrush(colorHexBrush)
示例13: draw
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setAlpha [as 别名]
def draw(self, painter, offset=Point()):
painter.setPen(self.pen)
color = QColor(self.pen.color())
color.setAlpha(50)
painter.setBrush(QColor(color))
painter.drawRect(self.origin.x + offset.x, self.origin.y + offset.y, self.size.width, self.size.height)