我们从Python开源项目中,提取了以下22个代码示例,用于说明如何使用PyQt5.QtCore.Qt.green()。
def process_finished(self, exit_code): format = self.ui.edit_stdout.currentCharFormat() format.setFontWeight(QFont.Bold) if exit_code == 0: if self._interrupted: color = Qt.red msg = ('Process interrupted by user') else: color = Qt.green msg = ('Process exited normally') else: color = Qt.red msg = ('Process exited with exit code %d' % exit_code) format.setForeground(color) self.ui.edit_stdout.setCurrentCharFormat(format) self.ui.edit_stdout.appendPlainText(msg) self.restore_gui() self.ui.edit_stdout.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard) self.process = None self.ui.btn_log.setEnabled(self.last_log_file is not None and os.path.isfile(self.last_log_file))
def draw_radar(self): """ Discards the current content and redraws all elements on the graphic scene. """ # decide which color to use bg_color, line_color = Qt.black, Qt.green self.scene.clear() self.scene.addRect(0, 0, self.width(), self.height(), brush=QBrush(bg_color)) self._add_crosshair() self._add_circles(self.circle_count, self.add_text_labels) # for each measurement, draw a line for measurement in self.measurements: assert isinstance(measurement, Measurement) added_time = self.added_time[measurement] self._add_measurement(measurement.distance, measurement.angle, added_time) # for the latest 2 measurements, draw an angle visualizer for measurement in self.measurements[-2:]: self._add_latest_input_line(measurement.angle)
def setColor(self): color = QColorDialog.getColor(Qt.green, self) if color.isValid(): self.colorLabel.setText(color.name()) self.colorLabel.setPalette(QPalette(color)) self.colorLabel.setAutoFillBackground(True)
def setupGraphics(self): self.rectangle = QGraphicsRectItem(self.boundingRect(), self) self.rectangle.setBrush(self.brush(color=Qt.green)) self.rectangle.setPen(self.pen(color=Qt.white))
def log_level_to_color(level): return { level.DEBUG: None, level.INFO: Qt.green, level.WARNING: Qt.yellow, level.ERROR: Qt.red, }.get(level.value)
def __init__(self): super().__init__() self.setGeometry(600, 200, 420, 320) self.setWindowTitle('Help') self.setWindowIcon(QIcon(ICON_PATH)) label = QLabel('Press anything on your keyboard to see what it does.') self.actionLabel = QLabel('Press something!') self.img = QLabel('img', self) self.img.setPixmap(QPixmap(HELP_IMG_PATH)) grid = QGridLayout() grid.setSpacing(4) grid.addWidget(self.img, 0, 0) grid.addWidget(label, 1, 0) grid.addWidget(self.actionLabel, 2, 0) myFont=QFont() myFont.setBold(True) myFont.setPixelSize(24) self.actionLabel.setFont(myFont) palette = QPalette() palette.setColor(QPalette.Foreground,Qt.green) self.actionLabel.setPalette(palette) self.setLayout(grid) self.show()
def validate(self): schemaData = decode_utf8(self.schemaView.toPlainText()) instanceData = decode_utf8(self.instanceEdit.toPlainText()) messageHandler = MessageHandler() schema = QXmlSchema() schema.setMessageHandler(messageHandler) schema.load(schemaData) errorOccurred = False if not schema.isValid(): errorOccurred = True else: validator = QXmlSchemaValidator(schema) if not validator.validate(instanceData): errorOccurred = True if errorOccurred: self.validationStatus.setText(messageHandler.statusMessage()) self.moveCursor(messageHandler.line(), messageHandler.column()) background = Qt.red else: self.validationStatus.setText("validation successful") background = Qt.green styleSheet = 'QLabel {background: %s; padding: 3px}' % QColor(background).lighter(160).name() self.validationStatus.setStyleSheet(styleSheet)
def __init__(self): super(Car, self).__init__() self.color = QBrush(Qt.green) self.wheelsAngle = 0.0 self.speed = 0.0 self.startTimer(1000 // 33) self.setFlag(QGraphicsItem.ItemIsMovable, True) self.setFlag(QGraphicsItem.ItemIsFocusable, True)
def brushChanged(self): style = Qt.BrushStyle(self.brushStyleComboBox.itemData( self.brushStyleComboBox.currentIndex(), IdRole)) if style == Qt.LinearGradientPattern: linearGradient = QLinearGradient(0, 0, 100, 100) linearGradient.setColorAt(0.0, Qt.white) linearGradient.setColorAt(0.2, Qt.green) linearGradient.setColorAt(1.0, Qt.black) self.renderArea.setBrush(QBrush(linearGradient)) elif style == Qt.RadialGradientPattern: radialGradient = QRadialGradient(50, 50, 50, 70, 70) radialGradient.setColorAt(0.0, Qt.white) radialGradient.setColorAt(0.2, Qt.green) radialGradient.setColorAt(1.0, Qt.black) self.renderArea.setBrush(QBrush(radialGradient)) elif style == Qt.ConicalGradientPattern: conicalGradient = QConicalGradient(50, 50, 150) conicalGradient.setColorAt(0.0, Qt.white) conicalGradient.setColorAt(0.2, Qt.green) conicalGradient.setColorAt(1.0, Qt.black) self.renderArea.setBrush(QBrush(conicalGradient)) elif style == Qt.TexturePattern: self.renderArea.setBrush(QBrush(QPixmap(':/images/brick.png'))) else: self.renderArea.setBrush(QBrush(Qt.green, style))
def reformatHeaders(self): text = self.headerTextFormatCombo.currentText() format = QTextCharFormat() if text == "Bold": format.setFontWeight(QFont.Bold) elif text == "Italic": format.setFontItalic(True) elif text == "Green": format.setForeground(Qt.green) self.calendar.setHeaderTextFormat(format)
def set_hidden(self, hide: bool): self.is_hidden = hide if hide: self.model_item.setForeground(Qt.green) self.getparent().hidden_children.append(self) else: self.model_item.setForeground(Qt.black) self.getparent().hidden_children.remove(self) self.getparent().save_metadata()
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()