当前位置: 首页>>代码示例>>Python>>正文


Python QPalette.color方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QPalette.color方法的典型用法代码示例。如果您正苦于以下问题:Python QPalette.color方法的具体用法?Python QPalette.color怎么用?Python QPalette.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui.QPalette的用法示例。


在下文中一共展示了QPalette.color方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: search

# 需要导入模块: from PyQt5.QtGui import QPalette [as 别名]
# 或者: from PyQt5.QtGui.QPalette import color [as 别名]
 def search (self):
     palette = QPalette()
     defbase = palette.color(QPalette.Base)
     deftext = palette.color(QPalette.Text)
     query = self.inputline.text().casefold()
     view = self.parent().view
     if view is not None:
         view.search(query, self.fields)
         self.searched.emit()
         
         if view.hits is None:
             palette.setColor(QPalette.Base, defbase)
             palette.setColor(QPalette.Text, deftext)
         elif view.hits:
             palette.setColor(QPalette.Base, FlPalette.hit)
             palette.setColor(QPalette.Text, FlPalette.dark)
         else:
             palette.setColor(QPalette.Base, FlPalette.miss)
             palette.setColor(QPalette.Text, FlPalette.dark)
         self.inputline.setPalette(palette)
开发者ID:bucaneer,项目名称:flint,代码行数:22,代码来源:nodelistwidget.py

示例2: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPalette [as 别名]
# 或者: from PyQt5.QtGui.QPalette import color [as 别名]
 def paintEvent(self, evt):
     """
     Protected method handling paint events.
     
     @param evt paint event (QPaintEvent)
     """
     if self.__grabbing:     # grabWindow() should just get the background
         return
     
     painter = QPainter(self)
     pal = QPalette(QToolTip.palette())
     font = QToolTip.font()
     
     handleColor = pal.color(QPalette.Active, QPalette.Highlight)
     handleColor.setAlpha(160)
     overlayColor = QColor(0, 0, 0, 160)
     textColor = pal.color(QPalette.Active, QPalette.Text)
     textBackgroundColor = pal.color(QPalette.Active, QPalette.Base)
     painter.drawPixmap(0, 0, self.__pixmap)
     painter.setFont(font)
     
     r = QRect(self.__selection)
     if not self.__selection.isNull():
         grey = QRegion(self.rect())
         if self.__mode == SnapshotRegionGrabber.Ellipse:
             reg = QRegion(r, QRegion.Ellipse)
         else:
             reg = QRegion(r)
         grey = grey.subtracted(reg)
         painter.setClipRegion(grey)
         painter.setPen(Qt.NoPen)
         painter.setBrush(overlayColor)
         painter.drawRect(self.rect())
         painter.setClipRect(self.rect())
         drawRect(painter, r, handleColor)
     
     if self.__showHelp:
         painter.setPen(textColor)
         painter.setBrush(textBackgroundColor)
         self.__helpTextRect = painter.boundingRect(
             self.rect().adjusted(2, 2, -2, -2),
             Qt.TextWordWrap, self.__helpText).translated(
             -self.__desktop.x(), -self.__desktop.y())
         self.__helpTextRect.adjust(-2, -2, 4, 2)
         drawRect(painter, self.__helpTextRect, textColor,
                  textBackgroundColor)
         painter.drawText(
             self.__helpTextRect.adjusted(3, 3, -3, -3),
             Qt.TextWordWrap, self.__helpText)
     
     if self.__selection.isNull():
         return
     
     # The grabbed region is everything which is covered by the drawn
     # rectangles (border included). This means that there is no 0px
     # selection, since a 0px wide rectangle will always be drawn as a line.
     txt = "{0:n}, {1:n} ({2:n} x {3:n})".format(
         self.__selection.x(), self.__selection.y(),
         self.__selection.width(), self.__selection.height())
     textRect = painter.boundingRect(self.rect(), Qt.AlignLeft, txt)
     boundingRect = textRect.adjusted(-4, 0, 0, 0)
     
     if textRect.width() < r.width() - 2 * self.__handleSize and \
        textRect.height() < r.height() - 2 * self.__handleSize and \
        r.width() > 100 and \
        r.height() > 100:
         # center, unsuitable for small selections
         boundingRect.moveCenter(r.center())
         textRect.moveCenter(r.center())
     elif r.y() - 3 > textRect.height() and \
             r.x() + textRect.width() < self.rect().width():
         # on top, left aligned
         boundingRect.moveBottomLeft(QPoint(r.x(), r.y() - 3))
         textRect.moveBottomLeft(QPoint(r.x() + 2, r.y() - 3))
     elif r.x() - 3 > textRect.width():
         # left, top aligned
         boundingRect.moveTopRight(QPoint(r.x() - 3, r.y()))
         textRect.moveTopRight(QPoint(r.x() - 5, r.y()))
     elif r.bottom() + 3 + textRect.height() < self.rect().bottom() and \
             r.right() > textRect.width():
         # at bottom, right aligned
         boundingRect.moveTopRight(QPoint(r.right(), r.bottom() + 3))
         textRect.moveTopRight(QPoint(r.right() - 2, r.bottom() + 3))
     elif r.right() + textRect.width() + 3 < self.rect().width():
         # right, bottom aligned
         boundingRect.moveBottomLeft(QPoint(r.right() + 3, r.bottom()))
         textRect.moveBottomLeft(QPoint(r.right() + 5, r.bottom()))
     
     # If the above didn't catch it, you are running on a very
     # tiny screen...
     drawRect(painter, boundingRect, textColor, textBackgroundColor)
     painter.drawText(textRect, Qt.AlignHCenter, txt)
     
     if (r.height() > self.__handleSize * 2 and
         r.width() > self.__handleSize * 2) or \
        not self.__mouseDown:
         self.__updateHandles()
         painter.setPen(Qt.NoPen)
         painter.setBrush(handleColor)
         painter.setClipRegion(
#.........这里部分代码省略.........
开发者ID:Darriall,项目名称:eric,代码行数:103,代码来源:SnapshotRegionGrabber.py

示例3: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPalette [as 别名]
# 或者: from PyQt5.QtGui.QPalette import color [as 别名]
 def paintEvent(self, evt):
     """
     Protected method handling paint events.
     
     @param evt paint event (QPaintEvent)
     """
     if self.__grabbing:     # grabWindow() should just get the background
         return
     
     painter = QPainter(self)
     pal = QPalette(QToolTip.palette())
     font = QToolTip.font()
     
     handleColor = pal.color(QPalette.Active, QPalette.Highlight)
     handleColor.setAlpha(160)
     overlayColor = QColor(0, 0, 0, 160)
     textColor = pal.color(QPalette.Active, QPalette.Text)
     textBackgroundColor = pal.color(QPalette.Active, QPalette.Base)
     painter.drawPixmap(0, 0, self.__pixmap)
     painter.setFont(font)
     
     pol = QPolygon(self.__selection)
     if not self.__selection.boundingRect().isNull():
         # Draw outline around selection.
         # Important: the 1px-wide outline is *also* part of the
         # captured free-region
         pen = QPen(handleColor, 1, Qt.SolidLine, Qt.SquareCap,
                    Qt.BevelJoin)
         painter.setPen(pen)
         painter.drawPolygon(pol)
         
         # Draw the grey area around the selection.
         grey = QRegion(self.rect())
         grey = grey - QRegion(pol)
         painter.setClipRegion(grey)
         painter.setPen(Qt.NoPen)
         painter.setBrush(overlayColor)
         painter.drawRect(self.rect())
         painter.setClipRect(self.rect())
         drawPolygon(painter, pol, handleColor)
     
     if self.__showHelp:
         painter.setPen(textColor)
         painter.setBrush(textBackgroundColor)
         self.__helpTextRect = painter.boundingRect(
             self.rect().adjusted(2, 2, -2, -2),
             Qt.TextWordWrap, self.__helpText).translated(
             -self.__desktop.x(), -self.__desktop.y())
         self.__helpTextRect.adjust(-2, -2, 4, 2)
         drawPolygon(painter, self.__helpTextRect, textColor,
                     textBackgroundColor)
         painter.drawText(
             self.__helpTextRect.adjusted(3, 3, -3, -3),
             Qt.TextWordWrap, self.__helpText)
     
     if self.__selection.isEmpty():
         return
     
     # The grabbed region is everything which is covered by the drawn
     # rectangles (border included). This means that there is no 0px
     # selection, since a 0px wide rectangle will always be drawn as a line.
     boundingRect = self.__selection.boundingRect()
     txt = "{0}, {1} ({2} x {3})".format(
         self.__locale.toString(boundingRect.x()),
         self.__locale.toString(boundingRect.y()),
         self.__locale.toString(boundingRect.width()),
         self.__locale.toString(boundingRect.height())
     )
     textRect = painter.boundingRect(self.rect(), Qt.AlignLeft, txt)
     boundingRect = textRect.adjusted(-4, 0, 0, 0)
     
     polBoundingRect = pol.boundingRect()
     if (textRect.width() <
         polBoundingRect.width() - 2 * self.__handleSize) and \
        (textRect.height() <
         polBoundingRect.height() - 2 * self.__handleSize) and \
        polBoundingRect.width() > 100 and \
        polBoundingRect.height() > 100:
         # center, unsuitable for small selections
         boundingRect.moveCenter(polBoundingRect.center())
         textRect.moveCenter(polBoundingRect.center())
     elif polBoundingRect.y() - 3 > textRect.height() and \
             polBoundingRect.x() + textRect.width() < self.rect().width():
         # on top, left aligned
         boundingRect.moveBottomLeft(
             QPoint(polBoundingRect.x(), polBoundingRect.y() - 3))
         textRect.moveBottomLeft(
             QPoint(polBoundingRect.x() + 2, polBoundingRect.y() - 3))
     elif polBoundingRect.x() - 3 > textRect.width():
         # left, top aligned
         boundingRect.moveTopRight(
             QPoint(polBoundingRect.x() - 3, polBoundingRect.y()))
         textRect.moveTopRight(
             QPoint(polBoundingRect.x() - 5, polBoundingRect.y()))
     elif (polBoundingRect.bottom() + 3 + textRect.height() <
           self.rect().bottom()) and \
             polBoundingRect.right() > textRect.width():
         # at bottom, right aligned
         boundingRect.moveTopRight(
             QPoint(polBoundingRect.right(), polBoundingRect.bottom() + 3))
#.........这里部分代码省略.........
开发者ID:pycom,项目名称:EricShort,代码行数:103,代码来源:SnapshotFreehandGrabber.py

示例4: __setup_overlay

# 需要导入模块: from PyQt5.QtGui import QPalette [as 别名]
# 或者: from PyQt5.QtGui.QPalette import color [as 别名]
    def __setup_overlay(self):
        tree_overlay = Overlay()
        tree_overlay.addWidget(self.view_switcher)

        ## set up stylesheet for buttons ##
        pal = QPalette()

        # get main text and highlight colors from palette
        txtcol = pal.color(QPalette.WindowText)
        txtcol.setAlphaF(0.5)

        # normal border is main text color @ 50% opacity
        border_color = "rgba{}".format(str(txtcol.getRgb()))
        # hovered border is palette highlight color
        # hover_border_color = "rgba{}".format(str(hlcol.getRgb()))

        # hovered btn-bg is highlight color @ 30% opacity
        hlcol = pal.color(QPalette.Highlight)
        hlcol.setAlphaF(0.3)
        hover_bg = "rgba{}".format(str(hlcol.getRgb()))

        btn_stylesheet = """QGroupBox {
                                background: transparent;
                                padding: 6px;
                           }
                           QToolButton {
                               background: transparent;
                               border: 1px solid %s;
                               border-radius: 2px;
                           }
                           QToolButton:checked {
                                background: palette(midlight);
                            }
                           QToolButton:hover {
                               background: %s;
                               border: 1px solid palette(highlight);
                           }
                           """ % (
            border_color,
            hover_bg,
        )

        ## create overlay for undo/redo buttons ##
        undo_overlay = Overlay("top", "right", btn_stylesheet)

        undo_overlay.addWidget(self.undo_btngroup)

        self.btn_undo.setDefaultAction(self.action_undo)
        self.btn_redo.setDefaultAction(self.action_redo)

        ## View switching buttons ##
        # chview_btngroup = QtWidgets.QButtonGroup(self.view_switcher)
        self.change_view_btngroup.setVisible(False)

        # chview_btngroup.addButton(self.btn_treeview)
        # chview_btngroup.setId(self.btn_treeview, 0)
        #
        # chview_btngroup.addButton(self.btn_colview)
        # chview_btngroup.setId(self.btn_colview, 1)

        # self.btn_treeview.setIcon(icons.get("view-tree"))
        # self.btn_colview.setIcon(icons.get("view-column"))

        # chview_btngroup.buttonClicked[int].connect(self.change_view)

        # and the overlay
        # chview_overlay = Overlay("bottom", "right", btn_stylesheet)
        # chview_overlay.addWidget(self.change_view_btngroup)

        ## create and populate main overlay ##
        main_overlay = OverlayCenter(self.fsview)
        main_overlay.addLayout(tree_overlay)
        main_overlay.addLayout(undo_overlay)
        # main_overlay.addLayout(chview_overlay)

        return main_overlay  # , tree_overlay#, btn_overlay
开发者ID:Kf4btg,项目名称:SkyModMan,代码行数:78,代码来源:manual_install_dialog.py


注:本文中的PyQt5.QtGui.QPalette.color方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。