我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用PyQt5.QtCore.Qt.darkGray()。
def __init__(self, parent=None): self.keywordFormat = self._text_format(Qt.blue) self.stringFormat = self._text_format(Qt.darkRed) self.commentFormat = self._text_format(Qt.darkGreen) self.decoratorFormat = self._text_format(Qt.darkGray) self.keywords = list(keyword_list) self.rules = [(QRegExp(r"\b%s\b" % kwd), self.keywordFormat) for kwd in self.keywords] + \ [(QRegExp(r"'.*'"), self.stringFormat), (QRegExp(r'".*"'), self.stringFormat), (QRegExp(r"#.*"), self.commentFormat), (QRegExp(r"@[A-Za-z_]+[A-Za-z0-9_]+"), self.decoratorFormat)] self.multilineStart = QRegExp(r"(''')|" + r'(""")') self.multilineEnd = QRegExp(r"(''')|" + r'(""")') super().__init__(parent)
def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) width = self.width() - 8 height = 36 previous = 0 percent_up = 0 for partition in self.partitions: color = self.color_list[self.partitions.index(partition)] percent = self.__percentage(width, partition.getSize(), self.max_capacity) if percent < 10: percent += 4 percent_up += 1 if percent_up >= 0 and percent >= width/35: percent -= 4 * percent_up percent_up = 0 print(percent, width) painter.setPen(color) painter.setBrush(color) painter.drawRect(QRectF(4+previous, 5, percent, 34)) previous += percent #Çerçeve painter.setPen(QColor(Qt.black)) painter.setBrush(Qt.NoBrush) painter.drawRoundedRect(QRectF(4, 4, width, height), 4, 4) #Parlakl?k painter.drawPixmap(QRect(6, 6, width-4, height-4), QPixmap(":/images/partitionwidget/light.svg")) #kareler line = 0 column = 0 for partition in self.partitions: painter.setPen(Qt.black) painter.setBrush(self.color_list[self.partitions.index(partition)]) if width - (line * 150) <= 150: column += 1 line = 0 painter.drawRoundedRect(QRectF(4 + (line * 150), (column*32)+64, 12, 12), 2, 2) painter.drawText(QRectF(24 + (line * 150), (column*32)+64, 30, 12), Qt.AlignVCenter | Qt.TextDontClip, partition.path) painter.setPen(Qt.darkGray) if partition.fileSystem: painter.drawText(QRectF(24 + (line * 150), (column*32)+78, 40, 12), Qt.AlignVCenter | Qt.TextDontClip, "{} {}".format(mbToGB(partition.getSize()), partition.fileSystem.type)) else: painter.drawText(QRectF(24 + (line * 150), (column*32)+78, 40, 12), Qt.AlignVCenter | Qt.TextDontClip, self.tr("{} Bilinmiyor").format(mbToGB(partition.getSize()))) line += 1