我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用PyQt5.QtCore.Qt.blue()。
def updatePlot(self, plot_num, value_tuple): # check if we have an existing plot. if not, initialize list of plot # values. if not plot_num in self._plots.keys(): self._plots[plot_num] = [] # if no pen has been assigned to this plot, create default if not plot_num in self._plot_pens.keys(): self._plot_pens[plot_num] = QPen(Qt.blue, 2.0) # if no draw method has been assigned to this plot, assign default if not plot_num in self._plot_draw_method.keys(): self._plot_draw_method[plot_num] = 'scatter' # add value to plot points list self._plots[plot_num].append(value_tuple) self.update()
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 data(self, role): if role in (Qt.EditRole, Qt.StatusTipRole): return self.formula() if role == Qt.DisplayRole: return self.display() t = str(self.display()) try: number = int(t) except ValueError: number = None if role == Qt.TextColorRole: if number is None: return QColor(Qt.black) elif number < 0: return QColor(Qt.red) return QColor(Qt.blue) if role == Qt.TextAlignmentRole: if t and (t[0].isdigit() or t[0] == '-'): return Qt.AlignRight | Qt.AlignVCenter return super(SpreadSheetItem, self).data(role)
def clipping(win): norm = isConvex(win.edges) if not norm: QMessageBox.warning(win, "??????!", "?????????? ?? ????????!???????? ?? ????? ???? ?????????!") for b in win.lines: win.pen.setColor(blue) cyrus_beck(b, win.edges, norm, win.scene, win.pen) win.pen.setColor(red)
def clipping(win): buf = win.scene.itemAt(now, QTransform()).rect() win.clip = [buf.left(), buf.right(), buf.top(), buf.bottom()] for b in win.lines: pass win.pen.setColor(blue) cohen_sutherland(b, win.clip, win) win.pen.setColor(red)
def selectedChanged(self, state): if state: self.mainRect.setPen(QPen(Qt.red)) else: self.mainRect.setPen(QPen(Qt.blue))
def penChanged(self): width = self.penWidthSpinBox.value() style = Qt.PenStyle(self.penStyleComboBox.itemData( self.penStyleComboBox.currentIndex(), IdRole)) cap = Qt.PenCapStyle(self.penCapComboBox.itemData( self.penCapComboBox.currentIndex(), IdRole)) join = Qt.PenJoinStyle(self.penJoinComboBox.itemData( self.penJoinComboBox.currentIndex(), IdRole)) self.renderArea.setPen(QPen(Qt.blue, width, style, cap, join))
def drawShape(self, painter): painter.fillPath(self.shape, Qt.blue)
def data(self, index, role): value = super(CustomSqlModel, self).data(index, role) if value is not None and role == Qt.DisplayRole: if index.column() == 0: return '#%d' % value elif index.column() == 2: return value.upper() if role == Qt.TextColorRole and index.column() == 1: return QColor(Qt.blue) return value
def createColorComboBox(self): comboBox = QComboBox() comboBox.addItem("Red", Qt.red) comboBox.addItem("Blue", Qt.blue) comboBox.addItem("Black", Qt.black) comboBox.addItem("Magenta", Qt.magenta) return comboBox
def __init__(self, parent=None): super(ScribbleArea, self).__init__(parent) self.setAttribute(Qt.WA_StaticContents) self.modified = False self.scribbling = False self.myPenWidth = 1 self.myPenColor = Qt.blue self.image = QImage() self.lastPoint = QPoint()
def _init(self): super()._init() self.sort_order = "0" self.user_sort_order = "0".zfill(7) self.allowed_children = () self.allowed_instances = 0 self.wizard = None self.name = "Comment" self.is_hidden = False self.forbidden_sequences = ["<!- -", "- ->", "--"] self.properties = {"<node_text>": PropertyText("Comment")} self.model_item = NodeStandardItem(self) self.model_item.setForeground(Qt.blue) self.update_item_name()
def run(self): if self.ui.cb_batch.isChecked(): self.last_log_file = None else: if self.params is None: self.create_params_file(self.params) return elif not os.path.exists(self.params): self.create_params_file(self.params) return if self.ui.tabWidget.currentIndex() == 0: args = self.command_line_args() elif self.ui.tabWidget.currentIndex() == 2: args = self.gui_command_line_args() self.update_result_tab() # # Start process self.ui.edit_stdout.clear() format = self.ui.edit_stdout.currentCharFormat() format.setFontWeight(QFont.Normal) format.setForeground(Qt.blue) self.ui.edit_stdout.setCurrentCharFormat(format) time_str = datetime.datetime.now().ctime() start_msg = '''\ Starting spyking circus at {time_str}. Command line call: {call} '''.format(time_str=time_str, call=' '.join(args)) self.ui.edit_stdout.appendPlainText(textwrap.dedent(start_msg)) format.setForeground(Qt.black) self.ui.edit_stdout.setCurrentCharFormat(format) self.ui.edit_stdout.appendPlainText('\n') self.process = QProcess(self) self.process.readyReadStandardOutput.connect(self.append_output) self.process.readyReadStandardError.connect(self.append_error) self.process.started.connect(self.process_started) self.process.finished.connect(self.process_finished) self.process.error.connect(self.process_errored) self._interrupted = False self.process.start(args[0], args[1:])
def add_point(point): global w if w.input_clip: w.pen.setColor(black) if w.point_now_clip is None: w.point_now_clip = point w.point_lock_clip = point add_row(w.table_rect) i = w.table_rect.rowCount() - 1 item_x = QTableWidgetItem("{0}".format(point.x())) item_y = QTableWidgetItem("{0}".format(point.y())) w.table_rect.setItem(i, 0, item_x) w.table_rect.setItem(i, 1, item_y) else: w.clip.append(point) w.point_now_clip = point add_row(w.table_rect) i = w.table_rect.rowCount() - 1 item_x = QTableWidgetItem("{0}".format(point.x())) item_y = QTableWidgetItem("{0}".format(point.y())) w.table_rect.setItem(i, 0, item_x) w.table_rect.setItem(i, 1, item_y) item_x = w.table_rect.item(i-1, 0) item_y = w.table_rect.item(i-1, 1) w.scene.addLine(point.x(), point.y(), float(item_x.text()), float(item_y.text()), w.pen) if w.input_pol: w.pen.setColor(blue) if w.point_now_pol is None: w.point_now_pol = point w.point_lock_pol = point add_row(w.table_pol) i = w.table_pol.rowCount() - 1 item_x = QTableWidgetItem("{0}".format(point.x())) item_y = QTableWidgetItem("{0}".format(point.y())) w.table_pol.setItem(i, 0, item_x) w.table_pol.setItem(i, 1, item_y) else: w.pol.append(point) w.point_now_pol = point add_row(w.table_pol) i = w.table_pol.rowCount() - 1 item_x = QTableWidgetItem("{0}".format(point.x())) item_y = QTableWidgetItem("{0}".format(point.y())) w.table_pol.setItem(i, 0, item_x) w.table_pol.setItem(i, 1, item_y) item_x = w.table_pol.item(i-1, 0) item_y = w.table_pol.item(i-1, 1) w.scene.addLine(point.x(), point.y(), float(item_x.text()), float(item_y.text()), w.pen)
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("\\*/")
def createTextFormatsGroupBox(self): self.textFormatsGroupBox = QGroupBox("Text Formats") self.weekdayColorCombo = self.createColorComboBox() self.weekdayColorCombo.setCurrentIndex( self.weekdayColorCombo.findText("Black")) self.weekdayColorLabel = QLabel("&Weekday color:") self.weekdayColorLabel.setBuddy(self.weekdayColorCombo) self.weekendColorCombo = self.createColorComboBox() self.weekendColorCombo.setCurrentIndex( self.weekendColorCombo.findText("Red")) self.weekendColorLabel = QLabel("Week&end color:") self.weekendColorLabel.setBuddy(self.weekendColorCombo) self.headerTextFormatCombo = QComboBox() self.headerTextFormatCombo.addItem("Bold") self.headerTextFormatCombo.addItem("Italic") self.headerTextFormatCombo.addItem("Plain") self.headerTextFormatLabel = QLabel("&Header text:") self.headerTextFormatLabel.setBuddy(self.headerTextFormatCombo) self.firstFridayCheckBox = QCheckBox("&First Friday in blue") self.mayFirstCheckBox = QCheckBox("May &1 in red") self.weekdayColorCombo.currentIndexChanged.connect( self.weekdayFormatChanged) self.weekendColorCombo.currentIndexChanged.connect( self.weekendFormatChanged) self.headerTextFormatCombo.currentIndexChanged.connect( self.reformatHeaders) self.firstFridayCheckBox.toggled.connect(self.reformatCalendarPage) self.mayFirstCheckBox.toggled.connect(self.reformatCalendarPage) checkBoxLayout = QHBoxLayout() checkBoxLayout.addWidget(self.firstFridayCheckBox) checkBoxLayout.addStretch() checkBoxLayout.addWidget(self.mayFirstCheckBox) outerLayout = QGridLayout() outerLayout.addWidget(self.weekdayColorLabel, 0, 0) outerLayout.addWidget(self.weekdayColorCombo, 0, 1) outerLayout.addWidget(self.weekendColorLabel, 1, 0) outerLayout.addWidget(self.weekendColorCombo, 1, 1) outerLayout.addWidget(self.headerTextFormatLabel, 2, 0) outerLayout.addWidget(self.headerTextFormatCombo, 2, 1) outerLayout.addLayout(checkBoxLayout, 3, 0, 1, 2) self.textFormatsGroupBox.setLayout(outerLayout) self.weekdayFormatChanged() self.weekendFormatChanged() self.reformatHeaders() self.reformatCalendarPage()