Python PyQt5.QtCore.Qt 模块,red() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtCore.Qt.red()

项目:spyking-circus    作者:spyking-circus    | 项目源码 | 文件源码
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))
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def add_bars(win):
    if len(win.edges) == 0:
        QMessageBox.warning(win, "????????!", "?? ?????? ??????????!")
        return
    win.pen.setColor(red)
    w.lines.append([[win.edges[0].x() - 15, win.edges[0].y() - 15],
                    [win.edges[1].x() - 15, win.edges[1].y() - 15]])
    add_row(w.table_bars)
    i = w.table_bars.rowCount() - 1
    item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() - 15 , win.edges[0].y() - 15))
    item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() - 15, win.edges[1].y() - 15))
    w.table_bars.setItem(i, 0, item_b)
    w.table_bars.setItem(i, 1, item_e)
    w.scene.addLine(win.edges[0].x() - 15, win.edges[0].y() - 15, win.edges[1].x() - 15, win.edges[1].y() - 15, w.pen)

    win.pen.setColor(red)
    w.lines.append([[win.edges[0].x() + 15, win.edges[0].y() + 15],
                    [win.edges[1].x() + 15, win.edges[1].y() + 15]])
    add_row(w.table_bars)
    i = w.table_bars.rowCount() - 1
    item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() + 15, win.edges[0].y() + 15))
    item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() + 15, win.edges[1].y() + 15))
    w.table_bars.setItem(i, 0, item_b)
    w.table_bars.setItem(i, 1, item_e)
    w.scene.addLine(win.edges[0].x() + 15, win.edges[0].y() + 15, win.edges[1].x() + 15, win.edges[1].y() + 15, w.pen)
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def clipping(win):
    if len(win.clip) <= 1:
        QMessageBox.warning(win, "??????!", "?????????? ?? ?????!")

    if len(win.pol) <= 1:
        QMessageBox.warning(win, "??????!", "????????????? ?? ?????!")

    if len(win.pol) > 1 and len(win.clip) > 1:
        norm = isConvex(win.clip)
        if not norm:
            QMessageBox.warning(win, "??????!", "?????????? ?? ????????!???????? ?? ????? ???? ?????????!")
        else:
            p = sutherland_hodgman(win.clip, win.pol, norm)
            if p:
                win.pen.setWidth(2)
                win.pen.setColor(red)
                win.scene.addPolygon(p, win.pen)
                win.pen.setWidth(1)
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = Scene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(Qt.white)
        self.bars.clicked.connect(lambda : set_bars(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: clipping(self))
        self.rect.clicked.connect(lambda: set_rect(self))
        self.ect.clicked.connect(lambda: add_bars(self))
        self.lines = []
        self.clip = None
        self.point_now = None
        self.input_bars = False
        self.input_rect = False
        self.pen = QPen(red)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
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)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def moveCursor(self, line, column):
        self.instanceEdit.moveCursor(QTextCursor.Start)

        for i in range(1, line):
            self.instanceEdit.moveCursor(QTextCursor.Down)

        for i in range(1, column):
            self.instanceEdit.moveCursor(QTextCursor.Right)

        extraSelections = []
        selection = QTextEdit.ExtraSelection()

        lineColor = QColor(Qt.red).lighter(160)
        selection.format.setBackground(lineColor)
        selection.format.setProperty(QTextFormat.FullWidthSelection, True)
        selection.cursor = self.instanceEdit.textCursor()
        selection.cursor.clearSelection()
        extraSelections.append(selection)

        self.instanceEdit.setExtraSelections(extraSelections)

        self.instanceEdit.setFocus()
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def reformatCalendarPage(self):
        if self.firstFridayCheckBox.isChecked():
            firstFriday = QDate(self.calendar.yearShown(),
                    self.calendar.monthShown(), 1)

            while firstFriday.dayOfWeek() != Qt.Friday:
                firstFriday = firstFriday.addDays(1)

            firstFridayFormat = QTextCharFormat()
            firstFridayFormat.setForeground(Qt.blue)

            self.calendar.setDateTextFormat(firstFriday, firstFridayFormat)

        # May 1st in Red takes precedence.
        if self.mayFirstCheckBox.isChecked():
            mayFirst = QDate(self.calendar.yearShown(), 5, 1)

            mayFirstFormat = QTextCharFormat()
            mayFirstFormat.setForeground(Qt.red)

            self.calendar.setDateTextFormat(mayFirst, mayFirstFormat)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
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)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
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)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def moveCursor(self, line, column):
        self.instanceEdit.moveCursor(QTextCursor.Start)

        for i in range(1, line):
            self.instanceEdit.moveCursor(QTextCursor.Down)

        for i in range(1, column):
            self.instanceEdit.moveCursor(QTextCursor.Right)

        extraSelections = []
        selection = QTextEdit.ExtraSelection()

        lineColor = QColor(Qt.red).lighter(160)
        selection.format.setBackground(lineColor)
        selection.format.setProperty(QTextFormat.FullWidthSelection, True)
        selection.cursor = self.instanceEdit.textCursor()
        selection.cursor.clearSelection()
        extraSelections.append(selection)

        self.instanceEdit.setExtraSelections(extraSelections)

        self.instanceEdit.setFocus()
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def reformatCalendarPage(self):
        if self.firstFridayCheckBox.isChecked():
            firstFriday = QDate(self.calendar.yearShown(),
                    self.calendar.monthShown(), 1)

            while firstFriday.dayOfWeek() != Qt.Friday:
                firstFriday = firstFriday.addDays(1)

            firstFridayFormat = QTextCharFormat()
            firstFridayFormat.setForeground(Qt.blue)

            self.calendar.setDateTextFormat(firstFriday, firstFridayFormat)

        # May 1st in Red takes precedence.
        if self.mayFirstCheckBox.isChecked():
            mayFirst = QDate(self.calendar.yearShown(), 5, 1)

            mayFirstFormat = QTextCharFormat()
            mayFirstFormat.setForeground(Qt.red)

            self.calendar.setDateTextFormat(mayFirst, mayFirstFormat)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
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)
项目:Osdag    作者:osdag-admin    | 项目源码 | 文件源码
def color_oldDB_sections(self, old_section, intg_section, combo_section):
        """display old sections in red color.

        Args:
            old_section(str): Old sections from IS 808 1984
            intg_section(str): Revised sections from IS 808 2007
            combo_section(QcomboBox): Beam/Column dropdown list

        Returns:

        """
        for col in old_section:
            if col in intg_section:
                indx = intg_section.index(str(col))
                combo_section.setItemData(indx, QBrush(QColor("red")), Qt.TextColorRole)

        duplicate = [i for i, x in enumerate(intg_section) if intg_section.count(x) > 1]
        for i in duplicate:
            combo_section.setItemData(i, QBrush(QColor("red")), Qt.TextColorRole)
项目:Osdag    作者:osdag-admin    | 项目源码 | 文件源码
def check_range(self, widget, lblwidget, min_value, max_value):
        """(QlineEdit, QLabel, Number, Number)---> NoneType
        Validating F_u(ultimate Strength) and F_y (Yield Strength) textfields
        """
        textStr = widget.text()
        val = int(textStr)
        if val < min_value or val > max_value:
            QMessageBox.about(self, 'Error', 'Please Enter a value between %s-%s' % (min_value, max_value))
            widget.clear()
            widget.setFocus()
            palette = QPalette()
            palette.setColor(QPalette.Foreground, Qt.red)
            lblwidget.setPalette(palette)
        else:
            palette = QPalette()
            lblwidget.setPalette(palette)
项目:Osdag    作者:osdag-admin    | 项目源码 | 文件源码
def color_oldDB_sections(self, old_section, intg_section, combo_section):
        """display old sections in red color.

        Args:
            old_section(str): Old sections from IS 808 1984
            intg_section(str): Revised sections from IS 808 2007
            combo_section(QcomboBox): Beam/Column dropdown list

        Returns:

        """
        for col in old_section:
            if col in intg_section:
                indx = intg_section.index(str(col))
                combo_section.setItemData(indx, QBrush(QColor("red")), Qt.TextColorRole)

        duplicate = [i for i, x in enumerate(intg_section) if intg_section.count(x) > 1]
        for i in duplicate:
            combo_section.setItemData(i, QBrush(QColor("red")), Qt.TextColorRole)
项目:Osdag    作者:osdag-admin    | 项目源码 | 文件源码
def color_oldDB_sections(self, old_section, intg_section, combo_section):
        """display old sections in red color.

        Args:
            old_section(str): Old sections from IS 808 1984
            intg_section(str): Revised sections from IS 808 2007
            combo_section(QcomboBox): Beam/Column dropdown list

        Returns:

        """
        for col in old_section:
            if col in intg_section:
                indx = intg_section.index(str(col))
                combo_section.setItemData(indx, QBrush(QColor("red")), Qt.TextColorRole)

        duplicate = [i for i, x in enumerate(intg_section) if intg_section.count(x) > 1]
        for i in duplicate:
            combo_section.setItemData(i, QBrush(QColor("red")), Qt.TextColorRole)
项目:Osdag    作者:osdag-admin    | 项目源码 | 文件源码
def check_range(self, widget, lblwidget, min_val, max_val):

        '''(QlineEdit,QLable,Number,Number)---> NoneType
        Validating F_u(ultimate Strength) and F_y (Yeild Strength) textfields
        '''
        text_str = widget.text()
        val = int(text_str)
        if(val < min_val or val > max_val):
            QMessageBox.about(self, 'Error', 'Please Enter a value between %s-%s' % (min_val, max_val))
            widget.clear()
            widget.setFocus()
            palette = QPalette()
            palette.setColor(QPalette.Foreground, Qt.red)
            lblwidget.setPalette(palette)
        else:
            palette = QPalette()
            lblwidget.setPalette(palette)
项目:Osdag    作者:osdag-admin    | 项目源码 | 文件源码
def color_oldDB_sections(self, old_section, intg_section, combo_section):
        """display old sections in red color.

        Args:
            old_section(str): Old sections from IS 808 1984
            intg_section(str): Revised sections from IS 808 2007
            combo_section(QcomboBox): Beam/Column dropdown list

        Returns:

        """
        for col in old_section:
            if col in intg_section:
                indx = intg_section.index(str(col))
                combo_section.setItemData(indx, QBrush(QColor("red")), Qt.TextColorRole)
        duplicate = [i for i, x in enumerate(intg_section) if intg_section.count(x) > 1]
        for i in duplicate:
            combo_section.setItemData(i, QBrush(QColor("red")), Qt.TextColorRole)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
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)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def moveCursor(self, line, column):
        self.instanceEdit.moveCursor(QTextCursor.Start)

        for i in range(1, line):
            self.instanceEdit.moveCursor(QTextCursor.Down)

        for i in range(1, column):
            self.instanceEdit.moveCursor(QTextCursor.Right)

        extraSelections = []
        selection = QTextEdit.ExtraSelection()

        lineColor = QColor(Qt.red).lighter(160)
        selection.format.setBackground(lineColor)
        selection.format.setProperty(QTextFormat.FullWidthSelection, True)
        selection.cursor = self.instanceEdit.textCursor()
        selection.cursor.clearSelection()
        extraSelections.append(selection)

        self.instanceEdit.setExtraSelections(extraSelections)

        self.instanceEdit.setFocus()
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.centralWidget = QWidget()
        self.setCentralWidget(self.centralWidget)

        self.createGroupBox()

        listWidget = QListWidget()

        for le in MainWindow.listEntries:
            listWidget.addItem(self.tr(le))

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(self.groupBox)
        mainLayout.addWidget(listWidget)
        self.centralWidget.setLayout(mainLayout)

        exitAction = QAction(self.tr("E&xit"), self,
                triggered=QApplication.instance().quit)

        fileMenu = self.menuBar().addMenu(self.tr("&File"))
        fileMenu.setPalette(QPalette(Qt.red))
        fileMenu.addAction(exitAction)

        self.setWindowTitle(self.tr("Language: %s") % self.tr("English"))
        self.statusBar().showMessage(self.tr("Internationalization Example"))

        if self.tr("LTR") == "RTL":
            self.setLayoutDirection(Qt.RightToLeft)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def reformatCalendarPage(self):
        if self.firstFridayCheckBox.isChecked():
            firstFriday = QDate(self.calendar.yearShown(),
                    self.calendar.monthShown(), 1)

            while firstFriday.dayOfWeek() != Qt.Friday:
                firstFriday = firstFriday.addDays(1)

            firstFridayFormat = QTextCharFormat()
            firstFridayFormat.setForeground(Qt.blue)

            self.calendar.setDateTextFormat(firstFriday, firstFridayFormat)

        # May 1st in Red takes precedence.
        if self.mayFirstCheckBox.isChecked():
            mayFirst = QDate(self.calendar.yearShown(), 5, 1)

            mayFirstFormat = QTextCharFormat()
            mayFirstFormat.setForeground(Qt.red)

            self.calendar.setDateTextFormat(mayFirst, mayFirstFormat)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
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)
项目:spyking-circus    作者:spyking-circus    | 项目源码 | 文件源码
def process_errored(self):
        try:
            exit_code = self.process.exitCode()
        except Exception:
            exit_code = 0
        format = self.ui.edit_stdout.currentCharFormat()
        format.setFontWeight(QFont.Bold)
        format.setForeground(Qt.red)
        self.ui.edit_stdout.setCurrentCharFormat(format)
        self.ui.edit_stdout.appendPlainText('Process exited with exit code' % exit_code)
        self.restore_gui()
        self.ui.edit_stdout.setTextInteractionFlags(Qt.TextSelectableByMouse |
                                                    Qt.TextSelectableByKeyboard)
        self.process = None
项目:coliform-project    作者:uprm-research-resto    | 项目源码 | 文件源码
def initUI(self):

        # QToolTip.setFont(QFont('SansSerif', 9))

        self.cwidget = GUICenterWidget()
        self.setCentralWidget(self.cwidget)

        # self.setToolTip('This is a <b>QWidget</b> widget')

        self.statusBar().showMessage('Ready')

        self.center()
        self.setWindowTitle('Coliform Control GUI')

        self.onewiretimer = QTimer(self)
        self.onewiretimer.timeout.connect(self.cwidget.onewireOn)
        self.onewiretimer.start(1000)

        # self.p = QPalette(self.palette())
        # self.p.setColor(QPalette.Window, QColor(53, 53, 53))
        # self.p.setColor(QPalette.WindowText, Qt.white)
        # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ToolTipBase, Qt.white)
        # self.p.setColor(QPalette.ToolTipText, Qt.white)
        # self.p.setColor(QPalette.Button, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ButtonText, Qt.white)
        # self.p.setColor(QPalette.BrightText, Qt.red)
        # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter())
        # self.p.setColor(QPalette.HighlightedText, Qt.black)
        # self.setPalette(self.p)

        self.show()
项目:coliform-project    作者:uprm-research-resto    | 项目源码 | 文件源码
def initUI(self):

        # QToolTip.setFont(QFont('SansSerif', 9))

        self.cwidget = CameraCenterWidget()
        self.setCentralWidget(self.cwidget)

        # self.setToolTip('This is a <b>QWidget</b> widget')

        self.center()
        self.setWindowTitle('Camera Control GUI')

        self.statusBarTimer = QTimer(self)
        self.statusBarTimer.timeout.connect(self.statusUpdate)
        self.statusBarTimer.start(100)

        # self.p = QPalette(self.palette())
        # self.p.setColor(QPalette.Window, QColor(53, 53, 53))
        # self.p.setColor(QPalette.WindowText, Qt.white)
        # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ToolTipBase, Qt.white)
        # self.p.setColor(QPalette.ToolTipText, Qt.white)
        # self.p.setColor(QPalette.Button, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ButtonText, Qt.white)
        # self.p.setColor(QPalette.BrightText, Qt.red)
        # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter())
        # self.p.setColor(QPalette.HighlightedText, Qt.black)
        # self.setPalette(self.p)

        self.show()
项目:coliform-project    作者:uprm-research-resto    | 项目源码 | 文件源码
def initUI(self):

        # QToolTip.setFont(QFont('SansSerif', 9))

        self.cwidget = RGBCenterWidget()
        self.setCentralWidget(self.cwidget)

        # self.setToolTip('This is a <b>QWidget</b> widget')

        self.center()
        self.setWindowTitle('RGB Sensor GUI')

        self.statusBarTimer = QTimer(self)
        self.statusBarTimer.timeout.connect(self.statusUpdate)
        self.statusBarTimer.start(100)

        # self.p = QPalette(self.palette())
        # self.p.setColor(QPalette.Window, QColor(53, 53, 53))
        # self.p.setColor(QPalette.WindowText, Qt.white)
        # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ToolTipBase, Qt.white)
        # self.p.setColor(QPalette.ToolTipText, Qt.white)
        # self.p.setColor(QPalette.Button, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ButtonText, Qt.white)
        # self.p.setColor(QPalette.BrightText, Qt.red)
        # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter())
        # self.p.setColor(QPalette.HighlightedText, Qt.black)
        # self.setPalette(self.p)

        self.show()
项目:binja_dynamics    作者:nccgroup    | 项目源码 | 文件源码
def highlight_bytes_at_address(self, segment, address, length, color=Qt.red, name="*"):
        """ Helper function for highlighting """
        self.get_widget(segment).highlight_address(address, length, color, name)
项目:binja_dynamics    作者:nccgroup    | 项目源码 | 文件源码
def highlight_instr_pointer(self, ip):
        """ Removes old instruction pointer highlights and creates a new one """
        if self.instr_pointer is not None:
            self.get_widget('stack').clear_highlight(self.instr_pointer)
        self.highlight_bytes_at_address('stack', ip, 1, Qt.red)
        self.instr_pointer = ip
项目:echolocation    作者:hgross    | 项目源码 | 文件源码
def _add_latest_input_line(self, angle):
        """Adds a line to the graphic scene that visualizes a scanned angle"""
        mx, my = self._get_middle()
        angle_rad = deg2rad(angle)
        angle_1_rad = deg2rad(angle - self.measurement_angle/2.0)
        angle_2_rad = deg2rad(angle + self.measurement_angle/2.0)
        length = max(self.width(), self.height())

        start_point = (mx, my)
        p1 = (mx + length * math.cos(angle_1_rad), my + length * math.sin(angle_1_rad))
        p2 = (mx + length * math.cos(angle_2_rad), my + length * math.sin(angle_2_rad))

        gradient_start_point, gradient_end_point = (mx, my), (mx + length * math.cos(angle_rad), my + length * math.sin(angle_rad))
        gradient = QLinearGradient(*gradient_start_point, *gradient_end_point)
        gradient.setColorAt(0, Qt.transparent)
        gradient.setColorAt(0.8, Qt.red)
        gradient.setColorAt(1, Qt.darkRed)

        triangle = QPolygonF()
        triangle.append(QPointF(*start_point))
        triangle.append(QPointF(*p1))
        triangle.append(QPointF(*p2))
        triangle.append(QPointF(*start_point))

        self.scene.addPolygon(triangle, pen=QPen(Qt.transparent), brush=QBrush(gradient))
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
def node_mode_to_color(mode):
    s = uavcan.protocol.NodeStatus()
    return {
        s.MODE_INITIALIZATION: Qt.cyan,
        s.MODE_MAINTENANCE: Qt.magenta,
        s.MODE_SOFTWARE_UPDATE: Qt.magenta,
        s.MODE_OFFLINE: Qt.red
    }.get(mode)
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
def node_health_to_color(health):
    s = uavcan.protocol.NodeStatus()
    return {
        s.HEALTH_WARNING: Qt.yellow,
        s.HEALTH_ERROR: Qt.magenta,
        s.HEALTH_CRITICAL: Qt.red,
    }.get(health)
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
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)
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
def _on_extraction_expression_changed(self):
        text = self._extraction_expression_box.text()
        try:
            expr = Expression(text)
            self._extraction_expression_box.setPalette(QApplication.palette())
        except Exception:
            _set_color(self._extraction_expression_box, QPalette.Base, Qt.red)
            return

        self._model.extraction_expression = expr
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def add_point(point):
    global w
    if w.input_rect:
        w.pen.setColor(black)
        if w.point_now_rect is None:
            w.point_now_rect = point
            w.point_lock = 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.edges.append(point)
            w.point_now_rect = 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_bars:
        w.pen.setColor(red)
        if w.point_now_bars is None:
            w.point_now_bars = point
        else:
            w.lines.append([[w.point_now_bars.x(), w.point_now_bars.y()],
                            [point.x(), point.y()]])

            add_row(w.table_bars)
            i = w.table_bars.rowCount() - 1
            item_b = QTableWidgetItem("[{0}, {1}]".format(w.point_now_bars.x(), w.point_now_bars.y()))
            item_e = QTableWidgetItem("[{0}, {1}]".format(point.x(), point.y()))
            w.table_bars.setItem(i, 0, item_b)
            w.table_bars.setItem(i, 1, item_e)
            w.scene.addLine(w.point_now_bars.x(), w.point_now_bars.y(), point.x(), point.y(), w.pen)
            w.point_now_bars = None
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
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)
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
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)
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def selectedChanged(self, state):
        if state:
            self.mainRect.setPen(QPen(Qt.red))
        else:
            self.mainRect.setPen(QPen(Qt.black))
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def selectedChanged(self, state):
        if state:
            self.mainRect.setPen(QPen(Qt.red))
        else:
            self.mainRect.setPen(QPen(Qt.blue))
项目:binja_dynamics    作者:ehennenfent    | 项目源码 | 文件源码
def highlight_bytes_at_address(self, segment, address, length, color=Qt.red, name="*"):
        """ Helper function for highlighting """
        self.get_widget(segment).highlight_address(address, length, color, name)
项目:binja_dynamics    作者:ehennenfent    | 项目源码 | 文件源码
def highlight_instr_pointer(self, ip):
        """ Removes old instruction pointer highlights and creates a new one """
        if self.instr_pointer is not None:
            self.get_widget('stack').clear_highlight(self.instr_pointer)
        self.highlight_bytes_at_address('stack', ip, 1, Qt.red)
        self.instr_pointer = ip
项目:PINCE    作者:korcankaraokcu    | 项目源码 | 文件源码
def data(self, QModelIndex, int_role=None):
        if not QModelIndex.isValid():
            return QVariant()
        if int_role == Qt.BackgroundColorRole:
            if QModelIndex.row() * self.column_count + QModelIndex.column() in self.breakpoint_list:
                return QVariant(QColor(Qt.red))
        elif int_role != Qt.DisplayRole:
            return QVariant()
        if self.data_array is None:
            return QVariant()
        return QVariant(self.data_array[QModelIndex.row() * self.column_count + QModelIndex.column()])
项目:PINCE    作者:korcankaraokcu    | 项目源码 | 文件源码
def data(self, QModelIndex, int_role=None):
        if not QModelIndex.isValid():
            return QVariant()
        if int_role == Qt.BackgroundColorRole:
            if QModelIndex.row() * self.column_count + QModelIndex.column() in self.breakpoint_list:
                return QVariant(QColor(Qt.red))
        elif int_role != Qt.DisplayRole:
            return QVariant()
        if self.data_array is None:
            return QVariant()
        return QVariant(
            SysUtils.aob_to_str(self.data_array[QModelIndex.row() * self.column_count + QModelIndex.column()]))
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
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("-->")
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
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)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def refresh(self):
        self.setUpdatesEnabled(False)

        pattern = self.patternComboBox.currentText()
        text = self.textComboBox.currentText()

        escaped = str(pattern)
        escaped.replace('\\', '\\\\')
        escaped.replace('"', '\\"')
        self.escapedPatternLineEdit.setText('"' + escaped + '"')

        rx = QRegExp(pattern)
        cs = Qt.CaseSensitive if self.caseSensitiveCheckBox.isChecked() else Qt.CaseInsensitive
        rx.setCaseSensitivity(cs)
        rx.setMinimal(self.minimalCheckBox.isChecked())
        syntax = self.syntaxComboBox.itemData(self.syntaxComboBox.currentIndex())
        rx.setPatternSyntax(syntax)

        palette = self.patternComboBox.palette()
        if rx.isValid():
            palette.setColor(QPalette.Text,
                    self.textComboBox.palette().color(QPalette.Text))
        else:
            palette.setColor(QPalette.Text, Qt.red)
        self.patternComboBox.setPalette(palette)

        self.indexEdit.setText(str(rx.indexIn(text)))
        self.matchedLengthEdit.setText(str(rx.matchedLength()))

        for i in range(self.MaxCaptures):
            self.captureLabels[i].setEnabled(i <= rx.captureCount())
            self.captureEdits[i].setEnabled(i <= rx.captureCount())
            self.captureEdits[i].setText(rx.cap(i))

        self.setUpdatesEnabled(True)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def colorForLanguage(self, language):
        hashValue = hash(language)
        red = 156 + (hashValue & 0x3F)
        green = 156 + ((hashValue >> 6) & 0x3F)
        blue = 156 + ((hashValue >> 12) & 0x3F)
        return QColor(red, green, blue)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.centralWidget = QWidget()
        self.setCentralWidget(self.centralWidget)

        self.createGroupBox()

        listWidget = QListWidget()

        for le in MainWindow.listEntries:
            listWidget.addItem(self.tr(le))

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(self.groupBox)
        mainLayout.addWidget(listWidget)
        self.centralWidget.setLayout(mainLayout)

        exitAction = QAction(self.tr("E&xit"), self,
                triggered=QApplication.instance().quit)

        fileMenu = self.menuBar().addMenu(self.tr("&File"))
        fileMenu.setPalette(QPalette(Qt.red))
        fileMenu.addAction(exitAction)

        self.setWindowTitle(self.tr("Language: %s") % self.tr("English"))
        self.statusBar().showMessage(self.tr("Internationalization Example"))

        if self.tr("LTR") == "RTL":
            self.setLayoutDirection(Qt.RightToLeft)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QPainter(self)
        painter.fillRect(event.rect(), Qt.white)
        painter.setFont(self.displayFont)

        redrawRect = event.rect()
        beginRow = redrawRect.top() // self.squareSize
        endRow = redrawRect.bottom() // self.squareSize
        beginColumn = redrawRect.left() // self.squareSize
        endColumn = redrawRect.right() // self.squareSize

        painter.setPen(Qt.gray)
        for row in range(beginRow, endRow + 1):
            for column in range(beginColumn, endColumn + 1):
                painter.drawRect(column * self.squareSize,
                        row * self.squareSize, self.squareSize,
                        self.squareSize)

        fontMetrics = QFontMetrics(self.displayFont)
        painter.setPen(Qt.black)
        for row in range(beginRow, endRow + 1):
            for column in range(beginColumn, endColumn + 1):
                key = row * self.columns + column
                painter.setClipRect(column * self.squareSize,
                        row * self.squareSize, self.squareSize,
                        self.squareSize)

                if key == self.lastKey:
                    painter.fillRect(column * self.squareSize + 1,
                            row * self.squareSize + 1, self.squareSize,
                            self.squareSize, Qt.red)

                key_ch = self._chr(key)
                painter.drawText(column * self.squareSize + (self.squareSize / 2) - fontMetrics.width(key_ch) / 2,
                        row * self.squareSize + 4 + fontMetrics.ascent(),
                        key_ch)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
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