我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用PyQt5.QtCore.Qt.darkGreen()。
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 updateLockStatus(self, status, reason): indicationColor = Qt.black if status == QCamera.Searching: self.ui.statusbar.showMessage("Focusing...") self.ui.lockButton.setText("Focusing...") indicationColor = Qt.yellow elif status == QCamera.Locked: self.ui.lockButton.setText("Unlock") self.ui.statusbar.showMessage("Focused", 2000) indicationColor = Qt.darkGreen elif status == QCamera.Unlocked: self.ui.lockButton.setText("Focus") if reason == QCamera.LockFailed: self.ui.statusbar.showMessage("Focus Failed", 2000) indicationColor = Qt.red palette = self.ui.lockButton.palette() palette.setColor(QPalette.ButtonText, indicationColor) self.ui.lockButton.setPalette(palette)
def __init__(self, parent=None): super(XmlSyntaxHighlighter, self).__init__(parent) self.highlightingRules = [] # Tag format. format = QTextCharFormat() format.setForeground(Qt.darkBlue) format.setFontWeight(QFont.Bold) pattern = QRegExp("(<[a-zA-Z:]+\\b|<\\?[a-zA-Z:]+\\b|\\?>|>|/>|</[a-zA-Z:]+>)") self.highlightingRules.append((pattern, format)) # Attribute format. format = QTextCharFormat() format.setForeground(Qt.darkGreen) pattern = QRegExp("[a-zA-Z:]+=") self.highlightingRules.append((pattern, format)) # Attribute content format. format = QTextCharFormat() format.setForeground(Qt.red) pattern = QRegExp("(\"[^\"]*\"|'[^']*')") self.highlightingRules.append((pattern, format)) # Comment format. self.commentFormat = QTextCharFormat() self.commentFormat.setForeground(Qt.lightGray) self.commentFormat.setFontItalic(True) self.commentStartExpression = QRegExp("<!--") self.commentEndExpression = QRegExp("-->")
def drawOutline(self, painter): painter.setPen(Qt.darkGreen) painter.setPen(Qt.DashLine) painter.setBrush(Qt.NoBrush) painter.drawRect(0, 0, 100, 100)
def paint_pause_indicator(self, painter): if self.show_pause_active: rect = self.__rect_for_row(self.pause_row) brush = QBrush(QColor(Qt.darkGreen)) pen = QPen(brush, 2, Qt.SolidLine) painter.setPen(pen) painter.drawLine(rect.topLeft(), rect.topRight())
def setStatusColor(self, rowIndex): """????????""" item = self.tableWidget.item(rowIndex, 6) if item.text() == "normal": item.setForeground(Qt.darkGreen) elif item.text() == "update": item.setForeground(Qt.darkRed) elif item.text() == "error": item.setForeground(Qt.darkYellow) elif item.text() == "none": item.setForeground(Qt.gray)
def __init__(self, parent=None): super().__init__(parent) width, height = 800, 800 self.setGeometry(width, height, width, height) # configs, can be changed at runtime self.circle_line_color = Qt.gray self.crosshair_line_color = Qt.gray self.text_label_color = Qt.darkGreen self.measured_distances_color = Qt.green self.circle_count = 10 self.dot_width = 10 self.line_width = 1 self.distance_measurement_angle = 15 self.measurement_angle = 10 # degrees that one sensor covers self.fade_out_time = 4 # older measurements will fade out over this time self.add_text_labels = False # data self.measurements = [] self.added_time = dict() # measurement -> timestamp # drawing timer self.timer = QTimer() self.timer.setInterval(80) self.timer.timeout.connect(self.draw_radar) self.timer.start() # internal canvas setup self.layout = QHBoxLayout() self.setLayout(self.layout) self.scene = QGraphicsScene() self.scene.setSceneRect(0, 0, width, height) self.canvas = QGraphicsView() self.canvas.setRenderHint(QPainter.Antialiasing) self.canvas.setFixedSize(width, height) self.canvas.setAlignment(Qt.AlignLeft) self.canvas.setScene(self.scene) self.canvas.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.canvas.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.layout.addWidget(self.canvas) # initial rendering self.draw_radar()
def __init__(self, parent=None): super(Highlighter, self).__init__(parent) keywordFormat = QTextCharFormat() keywordFormat.setForeground(Qt.darkBlue) keywordFormat.setFontWeight(QFont.Bold) keywordPatterns = ["\\bchar\\b", "\\bclass\\b", "\\bconst\\b", "\\bdouble\\b", "\\benum\\b", "\\bexplicit\\b", "\\bfriend\\b", "\\binline\\b", "\\bint\\b", "\\blong\\b", "\\bnamespace\\b", "\\boperator\\b", "\\bprivate\\b", "\\bprotected\\b", "\\bpublic\\b", "\\bshort\\b", "\\bsignals\\b", "\\bsigned\\b", "\\bslots\\b", "\\bstatic\\b", "\\bstruct\\b", "\\btemplate\\b", "\\btypedef\\b", "\\btypename\\b", "\\bunion\\b", "\\bunsigned\\b", "\\bvirtual\\b", "\\bvoid\\b", "\\bvolatile\\b"] self.highlightingRules = [(QRegExp(pattern), keywordFormat) for pattern in keywordPatterns] classFormat = QTextCharFormat() classFormat.setFontWeight(QFont.Bold) classFormat.setForeground(Qt.darkMagenta) self.highlightingRules.append((QRegExp("\\bQ[A-Za-z]+\\b"), classFormat)) singleLineCommentFormat = QTextCharFormat() singleLineCommentFormat.setForeground(Qt.red) self.highlightingRules.append((QRegExp("//[^\n]*"), singleLineCommentFormat)) self.multiLineCommentFormat = QTextCharFormat() self.multiLineCommentFormat.setForeground(Qt.red) quotationFormat = QTextCharFormat() quotationFormat.setForeground(Qt.darkGreen) self.highlightingRules.append((QRegExp("\".*\""), quotationFormat)) functionFormat = QTextCharFormat() functionFormat.setFontItalic(True) functionFormat.setForeground(Qt.blue) self.highlightingRules.append((QRegExp("\\b[A-Za-z0-9_]+(?=\\()"), functionFormat)) self.commentStartExpression = QRegExp("/\\*") self.commentEndExpression = QRegExp("\\*/")