Python源码示例:PyQt5.QtCore.Qt.black()

示例1
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.lock.clicked.connect(lambda: lock(self))
        self.lines = []
        self.edges = []
        self.clip = None
        self.point_now_rect = None
        self.point_now_bars = None
        self.point_lock = None
        self.input_bars = False
        self.input_rect = False
        self.pen = QPen(black) 
示例2
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511)
        self.mainview.setScene(self.scene)
        self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied)
        self.pen = QPen()
        self.color_line = QColor(Qt.black)
        self.color_bground = QColor(Qt.white)
        self.draw_once.clicked.connect(lambda: draw_once(self))
        self.clean_all.clicked.connect(lambda: clear_all(self))
        self.btn_bground.clicked.connect(lambda: get_color_bground(self))
        self.btn_line.clicked.connect(lambda: get_color_line(self))
        self.draw_centr.clicked.connect(lambda: draw_centr(self))
        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(self.what)
        layout.addWidget(self.other)
        self.setLayout(layout)
        self.circle.setChecked(True)
        self.canon.setChecked(True)
        #self.circle.toggled.connect(lambda : change_text(self)) 
示例3
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.poly.clicked.connect(lambda : set_pol(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.lock.clicked.connect(lambda: lock(self))
        self.clip = []
        self.pol = []
        self.point_now_clip = None
        self.point_now_pol = None
        self.point_lock_pol = None
        self.point_lock_clip = None
        self.input_pol = False
        self.input_clip = False
        self.pen = QPen(black) 
示例4
def _updateAutoForegroundColForeground(self, row):
        item = self.item(row, self._autoForegroundCol)
        if item is None: return

        try:
            value = float(item.data(self._role))
        except Exception as ex:
            value = 0 # if referenced item doesn't have value or not number, think it as default 0.

        if value > 0:
            color = Qt.red
        elif value < 0:
            color = Qt.darkGreen
        else:
            if item.background() == Qt.white: # for qdarkstyle
                color = Qt.black
            else:
                color = QColor('#C0C0C0')

        item.setForeground(color) 
示例5
def _getForeground(self, rowData, autoForegroundCol, item):

        # 如果@rowData的item个数小于等于@autoForegroundCol
        # 支持row数据比header少的状况
        try:
            value = rowData[autoForegroundCol]

            color = self.getForegroundOverride(value)
        except Exception as ex:
            color = None
        
        if color is None:
            if item.background() == Qt.white:
                color = Qt.black

            else: # for qdarkstyle
                color = QColor(192, 192, 192)
            
        return color 
示例6
def __init__(self):
        super(VideoStyleDark, self).__init__()
        palette = qApp.palette()
        palette.setColor(QPalette.Window, QColor(27, 35, 38))
        palette.setColor(QPalette.WindowText, QColor(234, 234, 234))
        palette.setColor(QPalette.Base, QColor(27, 35, 38))
        palette.setColor(QPalette.AlternateBase, QColor(12, 15, 16))
        palette.setColor(QPalette.ToolTipBase, QColor(27, 35, 38))
        palette.setColor(QPalette.ToolTipText, Qt.white)
        palette.setColor(QPalette.Text, QColor(234, 234, 234))
        palette.setColor(QPalette.Button, QColor(27, 35, 38))
        palette.setColor(QPalette.ButtonText, Qt.white)
        palette.setColor(QPalette.BrightText, QColor(100, 215, 222))
        palette.setColor(QPalette.Link, QColor(126, 71, 130))
        # palette.setColor(QPalette.Highlight, QColor(126, 71, 130))
        # palette.setColor(QPalette.HighlightedText, Qt.white)
        palette.setColor(QPalette.Disabled, QPalette.Light, Qt.black)
        palette.setColor(QPalette.Disabled, QPalette.Shadow, QColor(12, 15, 16))
        qApp.setPalette(palette) 
示例7
def __init__(self, types, parent=None, color=Qt.black):
        """
        :param types:                    渐变类型(0-透明,1-彩虹)
        :param parent:
        """
        super(CColorSlider, self).__init__(Qt.Horizontal, parent)
        self.setObjectName('Custom_Color_Slider')
        self.setCursor(Qt.PointingHandCursor)
        self.valueChanged.connect(self.onValueChanged)
        self._types = types
        self._color = color
        self._isFirstShow = True
        self._imageRainbow = None                       # 彩虹背景图
        self._imageAlphaColor = None                    # 带颜色透明图
        self._imageAlphaTmp = None                      # 透明方格
        self._imageAlpha = None                         # 带颜色透明背景和方格合成图
        self._imageCircle = None                        # 圆形滑块图
        self._imageCircleHover = None                   # 圆形滑块悬停图
        self.setToolTip('彩虹色' if self._types == self.TypeRainbow else '透明度') 
示例8
def _h_assign_feat_color(self, irow):

        feat_val = self.timeseries_data.loc[irow, self.feat_column]

        if (feat_val != feat_val):
            return Qt.black
        
        #this function can and should be optimized
        f_min = self.ui.feat_min_value.value()
        f_max = self.ui.feat_max_value.value()
        
        if f_min == f_max: #dummy range in case all the values are the same
            f_min, f_max = -1, 1
        elif f_min > f_max:
            return Qt.black

        nn = np.clip((feat_val - f_min)/(f_max - f_min), 0, 1) 
        ind = int(np.round(nn*(self.n_colors-1)))
        
        col = self.palette[ind]
        return col 
示例9
def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex):
        if self.colors:
            try:
                item = index.model().data(index)
                index = self.items.index(item) if item in self.items else int(item)
                color = self.colors[index]

                x, y, h = option.rect.x(), option.rect.y(), option.rect.height()

                rect = QRectF(x + 8, y + h / 2 - 8, 16, 16)
                painter.fillRect(rect, QColor("black"))
                rect = rect.adjusted(1, 1, -1, -1)
                painter.fillRect(rect, QColor(color.red(), color.green(), color.blue(), 255))
            except:
                super().paint(painter, option, index)
        else:
            super().paint(painter, option, index) 
示例10
def _updateAutoForegroundColForeground(self, row):
        item = self.item(row, self._autoForegroundCol)
        if item is None: return

        try:
            value = float(item.data(self._role))
        except Exception as ex:
            value = 0 # if referenced item doesn't have value or not number, think it as default 0.

        if value > 0:
            color = Qt.red
        elif value < 0:
            color = Qt.darkGreen
        else:
            if item.background() == Qt.white: # for qdarkstyle
                color = Qt.black
            else:
                color = QColor('#C0C0C0')

        item.setForeground(color) 
示例11
def _getForeground(self, rowData, autoForegroundCol, item):

        # 如果@rowData的item个数小于等于@autoForegroundCol
        # 支持row数据比header少的状况
        try:
            value = rowData[autoForegroundCol]

            color = self.getForegroundOverride(value)
        except Exception as ex:
            color = None
        
        if color is None:
            if item.background() == Qt.white:
                color = Qt.black

            else: # for qdarkstyle
                color = QColor(192, 192, 192)
            
        return color 
示例12
def refreshMergedModList(self):
        self.mergedModList.clear()
        for modName in sorted(self.__mergedModInfo):
            modPluginsState = self.getMergedModPluginsState(modName)
            color = {
                Dc.ModPluginsState.UNKNOWN: Dc.red,
                Dc.ModPluginsState.ACTIVE: None,
                Dc.ModPluginsState.MIXED: Dc.yellow,
                Dc.ModPluginsState.INACTIVE: Dc.green
            }[modPluginsState]
            stateDescription = {
                Dc.ModPluginsState.UNKNOWN: self.__tr("Unknown"),
                Dc.ModPluginsState.ACTIVE: self.__tr("All plugins active"),
                Dc.ModPluginsState.MIXED: self.__tr("Some plugins active"),
                Dc.ModPluginsState.INACTIVE: self.__tr("All plugins inactive")
            }[modPluginsState]
            item = QtWidgets.QTreeWidgetItem(self.mergedModList, [modName, stateDescription])
            for x in range(2):
                if color:
                    item.setBackground(x, color)
                    item.setForeground(x, Qt.black)
                item.setData(x, Qt.UserRole, {"modName": modName, "modPluginsState": modPluginsState})
            self.mergedModList.addTopLevelItem(item)
        self.mergedModList.resizeColumnToContents(0) 
示例13
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511)
        self.mainview.setScene(self.scene)
        self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied)
        self.pen = QPen()
        self.color_line = QColor(Qt.black)
        self.color_bground = QColor(Qt.white)
        self.draw_line.clicked.connect(lambda: draw_line(self))
        self.clean_all.clicked.connect(lambda : clear_all(self))
        self.btn_bground.clicked.connect(lambda: get_color_bground(self))
        self.btn_line.clicked.connect(lambda: get_color_line(self))
        self.draw_sun.clicked.connect(lambda: draw_sun(self))
        self.cda.setChecked(True) 
示例14
def get_color_line(win):
    color = QtWidgets.QColorDialog.getColor(initial=Qt.black, title="Цвет линии",
                                            options=QtWidgets.QColorDialog.DontUseNativeDialog)
    if color.isValid():
        win.color_line = color
        win.pen.setColor(color)
        s = QtWidgets.QGraphicsScene(0, 0, 10, 10)
        s.setBackgroundBrush(color)
        win.line_color.setScene(s) 
示例15
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = QGraphicsScene(0, 0, 711, 601)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(710, 600, QImage.Format_Alpha8)
        self.image.fill(black)
        self.pen = QPen(black)
        self.draw.clicked.connect(lambda: draw(self))
        self.dial_x.valueChanged.connect(lambda: draw(self))
        self.dial_y.valueChanged.connect(lambda: draw(self))
        self.dial_z.valueChanged.connect(lambda: draw(self))
        self.funcs.addItem("cos(x) * sin(z)")
        self.funcs.addItem("2 * cos(x * z)")
        self.funcs.addItem("exp(sin(sqrt(x^2 + z^2)))")
        self.funcs.addItem("x^2 / 20 + z^2 / 20")
        self.funcs.addItem("|sin(x) * sin(z)|") 
示例16
def draw(win):
    win.scene.clear()
    win.image.fill(black)
    tx = win.dial_x.value()
    ty = win.dial_y.value()
    tz = win.dial_z.value()

    if win.funcs.currentText() == "cos(x) * sin(z)":
        f = f1

    if win.funcs.currentText() == "2 * cos(x * z)":
        f = f2

    if win.funcs.currentText() == "exp(sin(sqrt(x^2 + z^2)))":
        f = f3

    if win.funcs.currentText() == "x^2 / 20 + z^2 / 20":
        f = f4

    if win.funcs.currentText() == "|sin(x) * sin(z)|":
        f = f5

    win.image = float_horizon(win.scene.width(), win.scene.height(), win.x_min.value(), win.x_max.value(), win.dx.value(),
            win.z_min.value(), win.z_max.value(), win.dz.value(), tx, ty, tz, f, win.image)

    pix = QPixmap()
    pix.convertFromImage(win.image)
    win.scene.addPixmap(pix) 
示例17
def get_color_line(win):
    color = QtWidgets.QColorDialog.getColor(initial=Qt.black, title="Цвет линии",
                                            options=QtWidgets.QColorDialog.DontUseNativeDialog)
    if color.isValid():
        win.color_line = color
        win.pen.setColor(color)
        s = QtWidgets.QGraphicsScene(0, 0, 10, 10)
        s.setBackgroundBrush(color)
        win.line_color.setScene(s) 
示例18
def _setAutoRowForeground(self, item):
        if self._autoForegroundCol is None:
            return

        # ignore 'Org.' column
        if self.__index and item.column() == 0:
            return

        # get forground of reference item
        row = item.row()

        refItem = self.item(row, self._autoForegroundCol)

        if not refItem:
            return

        # set forground same as reference item
        item.setForeground(refItem.foreground())

        # we still need to go through row if value of reference item changed
        if item.column() == self._autoForegroundCol:
            # get foreground for row
            color = self.getForegroundOverride(item.data(self._role))
            if color is None:
                if item.background() == Qt.white: # for qdarkstyle
                    color = Qt.black
                else:
                    color = Qt.white

            # no foreground changed
            if item.foreground() == color:
                return

            for i in range(self.columnCount()):
                if self.__index and i == 0: continue

                item = self.item(row, i)
                if item:
                    item.setForeground(color) 
示例19
def draw(self, painter: QPainter) -> None:
        if self.sourceIsPixmap():
            pixmap, offset = self.sourcePixmap(Qt.LogicalCoordinates, QGraphicsEffect.PadToEffectiveBoundingRect)
        else:
            pixmap, offset = self.sourcePixmap(Qt.DeviceCoordinates, QGraphicsEffect.PadToEffectiveBoundingRect)
            painter.setWorldTransform(QTransform())
        painter.setBrush(Qt.black)
        painter.drawRect(pixmap.rect())
        painter.setOpacity(self.opacity)
        painter.drawPixmap(offset, pixmap) 
示例20
def setBlackoutColors(self):
        global colors
        global orange
        colors = [Qt.red, Qt.yellow, Qt.darkYellow, Qt.green, Qt.darkGreen, orange, Qt.blue,Qt.cyan, Qt.darkCyan, Qt.magenta, Qt.darkMagenta, Qt.gray]

        # return
        # self.setStyleSheet("background-color: black")
        #self.Plot24.setBackgroundBrush(Qt.black)
        mainTitleBrush = QBrush(Qt.red)
        self.chart24.setTitleBrush(mainTitleBrush)
        self.chart5.setTitleBrush(mainTitleBrush)
        
        self.chart24.setBackgroundBrush(QBrush(Qt.black))
        self.chart24.axisX().setLabelsColor(Qt.white)
        self.chart24.axisY().setLabelsColor(Qt.white)
        titleBrush = QBrush(Qt.white)
        self.chart24.axisX().setTitleBrush(titleBrush)
        self.chart24.axisY().setTitleBrush(titleBrush)
        #self.Plot5.setBackgroundBrush(Qt.black)
        self.chart5.setBackgroundBrush(QBrush(Qt.black))
        self.chart5.axisX().setLabelsColor(Qt.white)
        self.chart5.axisY().setLabelsColor(Qt.white)
        self.chart5.axisX().setTitleBrush(titleBrush)
        self.chart5.axisY().setTitleBrush(titleBrush)
        
        #$ self.networkTable.setStyleSheet("QTableCornerButton::section{background-color: white;}")
        # self.networkTable.cornerWidget().setStylesheet("background-color: black")
        self.networkTable.setStyleSheet("QTableView {background-color: black;gridline-color: white;color: white} QTableCornerButton::section{background-color: white;}")
        headerStyle = "QHeaderView::section{background-color: white;border: 1px solid black;color: black;} QHeaderView::down-arrow,QHeaderView::up-arrow {background: none;}"
        self.networkTable.horizontalHeader().setStyleSheet(headerStyle)
        self.networkTable.verticalHeader().setStyleSheet(headerStyle) 
示例21
def setBlackoutColors(self):
        self.locationTable.setStyleSheet("QTableView {background-color: black;gridline-color: white;color: white} QTableCornerButton::section{background-color: white;}")
        headerStyle = "QHeaderView::section{background-color: white;border: 1px solid black;color: black;} QHeaderView::down-arrow,QHeaderView::up-arrow {background: none;}"
        self.locationTable.horizontalHeader().setStyleSheet(headerStyle)
        self.locationTable.verticalHeader().setStyleSheet(headerStyle)
        
        mainTitleBrush = QBrush(Qt.red)
        self.timeChart.setTitleBrush(mainTitleBrush)
        
        self.timeChart.setBackgroundBrush(QBrush(Qt.black))
        self.timeChart.axisX().setLabelsColor(Qt.white)
        self.timeChart.axisY().setLabelsColor(Qt.white)
        titleBrush = QBrush(Qt.white)
        self.timeChart.axisX().setTitleBrush(titleBrush)
        self.timeChart.axisY().setTitleBrush(titleBrush) 
示例22
def add(self, name, color=Qt.black, mode=QIcon.Normal, state=QIcon.Off):
        """添加或者更新一个指定mode和state的字体和颜色
        :param name:
        :param color:
        :param mode:
        :param state:
        """
        ms = self._getMode(mode) * self._getState(state)
        self.icons[ms] = [self.fontMap.get(name, ''), color]
        return self 
示例23
def createImage(self, color, alpha=255):
        self._color = QColor(color)
        self._color.setAlpha(255)
        self._image = QImage(self.size(), QImage.Format_ARGB32)

        painter = QPainter()
        painter.begin(self._image)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        # 背景色
        painter.fillRect(self.rect(), color)
        # 白色渐变
        gradient = QLinearGradient(0, 0, self.width(), 0)
        gradient.setColorAt(0, Qt.white)
        gradient.setColorAt(1, QColor.fromHslF(0.055, 0.42, 0.65, 0))
        painter.fillRect(self.rect(), gradient)
        # 黑色渐变
        gradient = QLinearGradient(0, self.height(), 0, 0)
        gradient.setColorAt(1, QColor.fromHslF(0.055, 0.42, 0.65, 0))
        gradient.setColorAt(0, Qt.black)
        painter.fillRect(self.rect(), gradient)
        painter.end()

        self.update()

        if self._image and self._pointerPos:
            self.colorChanged.emit(self._image.pixelColor(
                max(min(self._pointerPos.x(), self.width() - 1), 0),
                max(min(self._pointerPos.y(), self.height() - 1), 0)
            )) 
示例24
def Color(self, item):
        if item == 0:
            color = (self.vistaGrafico.backgroundBrush().color()
                     if self.vistaGrafico.backgroundBrush().color().isValid()
                     else QColor(Qt.white))
        elif item == 1:
            color = (self.vistaGrafico.chart().backgroundBrush().color()
                     if self.vistaGrafico.chart().backgroundBrush().color().isValid()
                     else QColor(Qt.white))
        elif item == 2:
            color = (self.vistaGrafico.chart().titleBrush().color()
                     if self.vistaGrafico.chart().titleBrush().color().isValid()
                     else QColor(Qt.black))
        elif item == 3:
            color = (self.vistaGrafico.chart().axisX().labelsBrush().color()
                     if self.vistaGrafico.chart().axisX().labelsBrush().color().isValid()
                     else QColor(Qt.black))
        elif item == 4:
            color = (self.vistaGrafico.chart().axisY().labelsBrush().color()
                     if self.vistaGrafico.chart().axisY().labelsBrush().color().isValid()
                     else QColor(Qt.black))
        elif item == 5:
            color = (self.vistaGrafico.chart().legend().labelColor()
                     if self.vistaGrafico.chart().legend().labelColor().isValid()
                     else QColor(Qt.black))
            
        color = QColorDialog.getColor(color, self)
        if color.isValid():
            if item == 0:
                self.vistaGrafico.setBackgroundBrush(color)
            elif item == 1:
                self.vistaGrafico.chart().setBackgroundBrush(color)
            elif item == 2:
                self.vistaGrafico.chart().setTitleBrush(color)
            elif item == 3:
                self.vistaGrafico.chart().axisX().setLabelsBrush(color)
            elif item == 4:
                self.vistaGrafico.chart().axisY().setLabelsBrush(color)
            elif item == 5:
                self.vistaGrafico.chart().legend().setLabelColor(color) 
示例25
def draw_border(self, painter: QtGui.QPainter) -> None:
        painter.setRenderHints(QtGui.QPainter.Antialiasing)
        painter.setRenderHints(QtGui.QPainter.HighQualityAntialiasing)
        painter.setRenderHint(QtGui.QPainter.TextAntialiasing)
        painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform)
        painter.setPen(QtGui.QPen(Qt.black))
        width = self.frameGeometry().width()
        height = self.frameGeometry().height()
        painter.setPen(QtCore.Qt.black)
        painter.drawLine(0, 0, width, 0)
        painter.drawLine(width, 0, width, height)
        painter.drawLine(0, height, width, height)
        painter.drawLine(0, 0, 0, height) 
示例26
def draw_apple(self, painter: QtGui.QPainter) -> None:
        apple_location = self.snake.apple_location
        if apple_location:
            painter.setRenderHints(QtGui.QPainter.HighQualityAntialiasing)
            painter.setPen(QtGui.QPen(Qt.black))
            painter.setBrush(QtGui.QBrush(Qt.green))

            painter.drawRect(apple_location.x * SQUARE_SIZE[0],
                             apple_location.y * SQUARE_SIZE[1],
                             SQUARE_SIZE[0],
                             SQUARE_SIZE[1]) 
示例27
def mark_stages(self, start_time, length, stage_name):
        """Mark stages, only add the new ones.

        Parameters
        ----------
        start_time : int
            start time in s of the epoch being scored.
        length : int
           duration in s of the epoch being scored.
        stage_name : str
            one of the stages defined in global stages.
        """
        y_pos = BARS['stage']['pos0']
        current_stage = STAGES.get(stage_name, STAGES['Unknown'])

        # the -1 is really important, otherwise we stay on the edge of the rect
        old_score = self.scene.itemAt(start_time + length / 2,
                                      y_pos +
                                      current_stage['pos0'] +
                                      current_stage['pos1'] - 1,
                                      self.transform())

        # check we are not removing the black border
        if old_score is not None and old_score.pen() == NoPen:
            lg.debug('Removing old score at {}'.format(start_time))
            self.scene.removeItem(old_score)
            self.idx_annot.remove(old_score)

        rect = QGraphicsRectItem(start_time,
                                 y_pos + current_stage['pos0'],
                                 length,
                                 current_stage['pos1'])
        rect.setPen(NoPen)
        rect.setBrush(current_stage['color'])
        self.scene.addItem(rect)
        self.idx_annot.append(rect) 
示例28
def mark_quality(self, start_time, length, qual_name):
        """Mark signal quality, only add the new ones.

        Parameters
        ----------
        start_time : int
            start time in s of the epoch being scored.
        length : int
           duration in s of the epoch being scored.
        qual_name : str
            one of the stages defined in global stages.
        """
        y_pos = BARS['quality']['pos0']
        height = 10

        # the -1 is really important, otherwise we stay on the edge of the rect
        old_score = self.scene.itemAt(start_time + length / 2,
                                      y_pos + height - 1,
                                      self.transform())

        # check we are not removing the black border
        if old_score is not None and old_score.pen() == NoPen:
            lg.debug('Removing old score at {}'.format(start_time))
            self.scene.removeItem(old_score)
            self.idx_annot.remove(old_score)

        if qual_name == 'Poor':
            rect = QGraphicsRectItem(start_time, y_pos, length, height)
            rect.setPen(NoPen)
            rect.setBrush(Qt.black)
            self.scene.addItem(rect)
            self.idx_annot.append(rect) 
示例29
def _drawSkel(self, worm_qimg, skel_dat, skel_colors = GOOD_SKEL_COLOURS):

        qPlg = {}
        for tt, dat in skel_dat.items():
            qPlg[tt] = QPolygonF()
            for p in dat:
                #do not add point if it is nan
                if p[0] == p[0]: 
                    qPlg[tt].append(QPointF(*p))


        if not qPlg or len(qPlg['skeleton']) == 0:
            return

        pen = QPen()
        pen.setWidth(1)

        painter = QPainter()
        painter.begin(worm_qimg)

        for k, pol_v in qPlg.items():
            color = skel_colors[k]
            pen.setColor(QColor(*color))
            painter.setPen(pen)
            painter.drawPolyline(pol_v)

        pen.setColor(Qt.black)
        painter.setBrush(Qt.white)
        painter.setPen(pen)

        radius = 3
        painter.drawEllipse(qPlg['skeleton'][0], radius, radius)
        painter.drawEllipse(QPointF(0,0), radius, radius)

        painter.end() 
示例30
def drawrect(self, row, col):
        painter = QPainter(self._image)
        painter.fillRect(
            (col + self.border) * self.box_size,
            (row + self.border) * self.box_size,
            self.box_size, self.box_size,
            Qt.black)