Python PySide.QtGui 模块,QPainter() 实例源码

我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用PySide.QtGui.QPainter()

项目:rfcat-firsttry    作者:atlas0fd00m    | 项目源码 | 文件源码
def paintEvent(self, event):
        self._draw_graph()
        self._draw_reticle()

        painter = QtGui.QPainter(self)
        try:
            painter.setRenderHint(QtGui.QPainter.Antialiasing)
            painter.setPen(QtGui.QPen())
            painter.setBrush(QtGui.QBrush())

            if self._graph:
                painter.drawPixmap(0, 0, self._graph)

            if self._path_max:
                painter.setPen(Qt.green)
                painter.drawPath(self._path_max)

            painter.setOpacity(0.5)
            if self._reticle:
                painter.drawPixmap(0, 0, self._reticle)
        finally:
            painter.end()
项目:CyclopsVFX-Unity    作者:geoffroygivry    | 项目源码 | 文件源码
def paintEvent(self, event):
        '''Paint the custom look'''

        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.RenderHint.HighQualityAntialiasing)
        painter.setFont(self.font)

        if self.mouseOver:
            self.indicator.setVisible(True)
        else:
            self.indicator.setVisible(False)

        if (self.active or self.hasFocus()) and not self.mouseOver:
            # when keyboard has shifted focus onto this widget
            painter.setPen(self.color.lighter())

        else:
            painter.setPen(self.color)

        painter.drawText(self.rect(), QtCore.Qt.AlignCenter, str(self.value))
项目:CyclopsVFX-Unity    作者:geoffroygivry    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        parent = self.parentWidget()

        pieRect = QtCore.QRect(1, 1, self.width()-2, self.height()-2)
        startAngle = 0 * 16

        if self.currentIndex() == 0:
            # STATUS = WAITING
            painter.drawEllipse(pieRect)
        elif self.currentIndex() == 1:
            # STATUS = IN PROGGRESS
            painter.setPen(QtGui.QColor(0,0,0,0))
            painter.setBrush(QtGui.QColor(255, 140, 30))
            startAngle = 90 * 16
            spanAngle = self.currentIndex() * 270 * 16
            painter.drawPie(pieRect, startAngle, spanAngle)
        elif self.currentIndex() == 2:
            # STATUS = FINISHED
            painter.setPen(QtGui.QColor(0,0,0,0))
            painter.setBrush(QtGui.QColor('darkGreen'))
            spanAngle = self.currentIndex() * 360 * 16
            painter.drawPie(pieRect, startAngle, spanAngle)
项目:CyclopsVFX-Unity    作者:geoffroygivry    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        pen = painter.pen()
        if self.active or self.hasFocus():
            pen.setColor(self.activeColor)
        else:
            pen.setColor(self.inactiveColor)
        pen.setWidth(3)
        pen.setCapStyle(QtCore.Qt.PenCapStyle.RoundCap)
        painter.setPen(pen)        
        polygon1 = QtGui.QPolygon()
        polygon1 << QtCore.QPoint(self.padding, self.padding) << QtCore.QPoint(self.width() - self.padding, self.height() - self.padding)
        polygon2 = QtGui.QPolygon()
        polygon2 << QtCore.QPoint(self.padding,self.height() - self.padding) << QtCore.QPoint(self.width() - self.padding, self.padding)

        polygon1.translate(0,1)
        polygon2.translate(0,1)
        painter.drawPolyline(polygon1)
        painter.drawPolyline(polygon2)
项目:rfcat    作者:EnhancedRadioDevices    | 项目源码 | 文件源码
def paintEvent(self, event):
        self._draw_graph()
        self._draw_reticle()

        painter = QtGui.QPainter(self)
        try:
            painter.setRenderHint(QtGui.QPainter.Antialiasing)
            painter.setPen(QtGui.QPen())
            painter.setBrush(QtGui.QBrush())

            if self._graph:
                painter.drawPixmap(0, 0, self._graph)

            if self._path_max:
                painter.setPen(Qt.green)
                painter.drawPath(self._path_max)

            painter.setOpacity(0.5)
            if self._reticle:
                painter.drawPixmap(0, 0, self._reticle)
        finally:
            painter.end()
项目:rfcat    作者:atlas0fd00m    | 项目源码 | 文件源码
def paintEvent(self, event):
        self._draw_graph()
        self._draw_reticle()

        painter = QtGui.QPainter(self)
        try:
            painter.setRenderHint(QtGui.QPainter.Antialiasing)
            painter.setPen(QtGui.QPen())
            painter.setBrush(QtGui.QBrush())

            if self._graph:
                painter.drawPixmap(0, 0, self._graph)

            if self._path_max:
                painter.setPen(Qt.green)
                painter.drawPath(self._path_max)

            painter.setOpacity(0.5)
            if self._reticle:
                painter.drawPixmap(0, 0, self._reticle)
        finally:
            painter.end()
项目:HORD    作者:ilija139    | 项目源码 | 文件源码
def paintEvent(self, event):

        qp = QtGui.QPainter()
        qp.begin(self)
        # Data info
        qp.drawLine(530, 60, 530, 170)
        qp.drawLine(530, 60, 795, 60)
        qp.drawLine(795, 60, 795, 170)
        qp.drawLine(530, 170, 795, 170)
        # Run info
        qp.drawLine(2, 475, 2, 585)
        qp.drawLine(2, 475, 195, 475)
        qp.drawLine(195, 475, 195, 585)
        qp.drawLine(2, 585, 195, 585)
        # Search box and RS box
        qp.drawLine(3, 210, 3, 410)
        qp.drawLine(3, 210, 795, 210)
        qp.drawLine(400, 210, 400, 410)
        qp.drawLine(3, 410, 795, 410)
        qp.drawLine(795, 210, 795, 410)
        qp.end()
项目:nuke    作者:Kagarrache    | 项目源码 | 文件源码
def paintEvent(self, event):
        '''Paint the custom look'''

        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.RenderHint.HighQualityAntialiasing)
        painter.setFont(self.font)

        if self.mouseOver:
            self.indicator.setVisible(True)
        else:
            self.indicator.setVisible(False)

        if (self.active or self.hasFocus()) and not self.mouseOver:
            # when keyboard has shifted focus onto this widget
            painter.setPen(self.color.lighter())

        else:
            painter.setPen(self.color)

        painter.drawText(self.rect(), QtCore.Qt.AlignCenter, str(self.value))
项目:nuke    作者:Kagarrache    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        parent = self.parentWidget()

        pieRect = QtCore.QRect(1, 1, self.width()-2, self.height()-2)
        startAngle = 0 * 16

        if self.currentIndex() == 0:
            # STATUS = WAITING
            painter.drawEllipse(pieRect)
        elif self.currentIndex() == 1:
            # STATUS = IN PROGGRESS
            painter.setPen(QtGui.QColor(0,0,0,0))
            painter.setBrush(QtGui.QColor(255, 140, 30))
            startAngle = 90 * 16
            spanAngle = self.currentIndex() * 270 * 16
            painter.drawPie(pieRect, startAngle, spanAngle)
        elif self.currentIndex() == 2:
            # STATUS = FINISHED
            painter.setPen(QtGui.QColor(0,0,0,0))
            painter.setBrush(QtGui.QColor('darkGreen'))
            spanAngle = self.currentIndex() * 360 * 16
            painter.drawPie(pieRect, startAngle, spanAngle)
项目:nuke    作者:Kagarrache    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        pen = painter.pen()
        if self.active or self.hasFocus():
            pen.setColor(self.activeColor)
        else:
            pen.setColor(self.inactiveColor)
        pen.setWidth(3)
        pen.setCapStyle(QtCore.Qt.PenCapStyle.RoundCap)
        painter.setPen(pen)        
        polygon1 = QtGui.QPolygon()
        polygon1 << QtCore.QPoint(self.padding, self.padding) << QtCore.QPoint(self.width() - self.padding, self.height() - self.padding)
        polygon2 = QtGui.QPolygon()
        polygon2 << QtCore.QPoint(self.padding,self.height() - self.padding) << QtCore.QPoint(self.width() - self.padding, self.padding)

        polygon1.translate(0,1)
        polygon2.translate(0,1)
        painter.drawPolyline(polygon1)
        painter.drawPolyline(polygon2)
项目:PandwaRF    作者:ComThings    | 项目源码 | 文件源码
def paintEvent(self, event):
        self._draw_graph()
        self._draw_reticle()

        painter = QtGui.QPainter(self)
        try:
            painter.setRenderHint(QtGui.QPainter.Antialiasing)
            painter.setPen(QtGui.QPen())
            painter.setBrush(QtGui.QBrush())

            if self._graph:
                painter.drawPixmap(0, 0, self._graph)

            if self._path_max:
                painter.setPen(Qt.green)
                painter.drawPath(self._path_max)

            painter.setOpacity(0.5)
            if self._reticle:
                painter.drawPixmap(0, 0, self._reticle)
        finally:
            painter.end()
项目:TWTools    作者:ZeX2    | 项目源码 | 文件源码
def paintEvent(self, event):
        pix = self.pixmap_hover if self.underMouse() else self.pixmap
        if self.isDown():
            pix = self.pixmap_pressed

        painter = QtGui.QPainter(self)
        painter.drawPixmap(event.rect(), pix)
项目:rfcat-firsttry    作者:atlas0fd00m    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:CyclopsVFX-Unity    作者:geoffroygivry    | 项目源码 | 文件源码
def paintEvent(self, event):
        '''Paint the button grey if not highlighted, else yellow'''

        painter = QtGui.QPainter(self)
        colour = QtGui.QColor(247, 147, 30, 150)
        gradient = QtGui.QLinearGradient(QtCore.QPoint(0,0), QtCore.QPoint(self.width()/2, 0))
        gradient.setColorAt(0, QtCore.Qt.transparent)
        gradient.setColorAt(1, colour)
        gradient.setSpread(QtGui.QGradient.ReflectSpread)
        painter.setBrush(QtGui.QBrush(gradient))
        painter.setPen(QtCore.Qt.transparent)
        rect = QtCore.QRect(0,0,self.width(),self.height())
        painter.drawRect(rect)
项目:CyclopsVFX-Unity    作者:geoffroygivry    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        currentIndex = self.currentIndex()
        painter.setPen(QtGui.QColor(0,0,0,0))

        if currentIndex == 0:
            progress =  .1
            if self.active or self.hasFocus():
                painter.setBrush(self.colWaiting.lighter())
            else:
                painter.setBrush(self.colWaiting)
        elif currentIndex == 1:
            progress = .6
            if self.active or self.hasFocus():
                painter.setBrush(self.colInProgress.lighter())
            else:
                painter.setBrush(self.colInProgress)
        elif currentIndex == 2:
            progress = 1
            if self.active or self.hasFocus():
                painter.setBrush(self.colFinished.lighter())
            else:
                painter.setBrush(self.colFinished)
        barRect = QtCore.QRect(0, self.height() * .25, (self.width()) * progress, self.height() * .5)
        painter.drawRect(barRect)

        outline = QtCore.QRect(1, self.height() * .25, (self.width())-2, self.height() * .5)
        painter.setBrush(QtGui.QColor(0,0,0,0))
        painter.setPen(QtGui.QColor(0,0,0,255))
        painter.drawRect(outline)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def UpdateColors(self):
        self.regenerateElectrodes(self.ElectrodeData.timeStep)
        for node in self.NodeIds:
            self.unselectNodes(node)
            try:
                temp = self.ElectrodeData.graphWidget.partition[node.counter]
            except IndexError:
                temp = 0 

            if self.ElectrodeData.ScalarSize: 
                Size = eval('self.ElectrodeData.graphWidget.'+self.ElectrodeData.electrodeSizeFactor+'[node.counter-1]')
                node.setNodeSize(Size,self.ElectrodeData.electrodeSizeFactor)
            else: 
                Size = 0.4 
                node.setNodeSize(Size,"nothing to Display")

            if not(self.ElectrodeData.nodeSizeFactor == 1):
                node.ScalarNodeSize(self.ElectrodeData.nodeSizeFactor)

        if self.ElectrodeData.Glyph:
            for node in self.NodeIds:
                node.setGlyph(True)

        if self.ElectrodeData.ElectrodeScreenshot:
            pixmap = QtGui.QImage(self.scene.sceneRect().size().toSize())
            pAin = QtGui.QPainter(pixmap)
            self.scene.render(pAin,QtCore.QRectF(self.width/4+50, self.height/4+50, 3*self.width/6,3*self.height/6))
            fileName = str("Time_"+str(self.ElectrodeData.timeStep)+"_Syllable_"+str(self.ElectrodeData.syllableUnit)+"_Alg_"+str(self.ElectrodeData.clusterActivated)+".png")
            pixmap1 = QtGui.QPixmap.fromImage(pixmap)
项目:Electrify    作者:jyapayne    | 项目源码 | 文件源码
def paintEvent(self, event=None):
        painter = QtGui.QPainter(self)
        if self.color is not None:
            painter.setBrush(QtGui.QBrush(self.color))
            rect = self.rect()
            margins = self.contentsMargins()
            new_rect = QtCore.QRect(rect.left()+margins.left(),
                                    rect.top()+margins.top(),
                                    rect.width()-margins.right()*2,
                                    rect.height()-margins.bottom()*2)
            painter.drawRect(new_rect)
项目:rfcat    作者:EnhancedRadioDevices    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:rfcat    作者:atlas0fd00m    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:tdoa    作者:xiongyihui    | 项目源码 | 文件源码
def paintEvent(self, e):

        painter = QtGui.QPainter()
        painter.begin(self)
        self.drawBars(painter)
        painter.end()
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def numberbarPaint(self, number_bar, event):
            font_metrics = self.fontMetrics()
            current_line = self.document().findBlock(self.textCursor().position()).blockNumber() + 1

            block = self.firstVisibleBlock()
            line_count = block.blockNumber()
            painter = QtGui.QPainter(number_bar)
            painter.fillRect(event.rect(), self.palette().base())

            # Iterate over all visible text blocks in the document.
            while block.isValid():
                line_count += 1
                block_top = self.blockBoundingGeometry(block).translated(self.contentOffset()).top()

                # Check if the position of the block is out side of the visible
                # area.
                if not block.isVisible() or block_top >= event.rect().bottom():
                    break

                # We want the line number for the selected line to be bold.
                if line_count == current_line:
                    font = painter.font()
                    font.setBold(True)
                    painter.setFont(font)
                else:
                    font = painter.font()
                    font.setBold(False)
                    painter.setFont(font)

                # Draw the line number right justified at the position of the line.
                paint_rect = QtCore.QRect(0, block_top, number_bar.width(), font_metrics.height())
                painter.drawText(paint_rect, QtCore.Qt.AlignRight, unicode(line_count))

                block = block.next()

            painter.end()
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def numberbarPaint(self, number_bar, event):
            font_metrics = self.fontMetrics()
            current_line = self.document().findBlock(self.textCursor().position()).blockNumber() + 1

            block = self.firstVisibleBlock()
            line_count = block.blockNumber()
            painter = QtGui.QPainter(number_bar)
            painter.fillRect(event.rect(), self.palette().base())

            # Iterate over all visible text blocks in the document.
            while block.isValid():
                line_count += 1
                block_top = self.blockBoundingGeometry(block).translated(self.contentOffset()).top()

                # Check if the position of the block is out side of the visible
                # area.
                if not block.isVisible() or block_top >= event.rect().bottom():
                    break

                # We want the line number for the selected line to be bold.
                if line_count == current_line:
                    font = painter.font()
                    font.setBold(True)
                    painter.setFont(font)
                else:
                    font = painter.font()
                    font.setBold(False)
                    painter.setFont(font)

                # Draw the line number right justified at the position of the line.
                paint_rect = QtCore.QRect(0, block_top, number_bar.width(), font_metrics.height())
                painter.drawText(paint_rect, QtCore.Qt.AlignRight, unicode(line_count))

                block = block.next()

            painter.end()
项目:nuke    作者:Kagarrache    | 项目源码 | 文件源码
def paintEvent(self, event):
        '''Paint the button grey if not highlighted, else yellow'''

        painter = QtGui.QPainter(self)
        colour = QtGui.QColor(247, 147, 30, 150)
        gradient = QtGui.QLinearGradient(QtCore.QPoint(0,0), QtCore.QPoint(self.width()/2, 0))
        gradient.setColorAt(0, QtCore.Qt.transparent)
        gradient.setColorAt(1, colour)
        gradient.setSpread(QtGui.QGradient.ReflectSpread)
        painter.setBrush(QtGui.QBrush(gradient))
        painter.setPen(QtCore.Qt.transparent)
        rect = QtCore.QRect(0,0,self.width(),self.height())
        painter.drawRect(rect)
项目:nuke    作者:Kagarrache    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        currentIndex = self.currentIndex()
        painter.setPen(QtGui.QColor(0,0,0,0))

        if currentIndex == 0:
            progress =  .1
            if self.active or self.hasFocus():
                painter.setBrush(self.colWaiting.lighter())
            else:
                painter.setBrush(self.colWaiting)
        elif currentIndex == 1:
            progress = .6
            if self.active or self.hasFocus():
                painter.setBrush(self.colInProgress.lighter())
            else:
                painter.setBrush(self.colInProgress)
        elif currentIndex == 2:
            progress = 1
            if self.active or self.hasFocus():
                painter.setBrush(self.colFinished.lighter())
            else:
                painter.setBrush(self.colFinished)
        barRect = QtCore.QRect(0, self.height() * .25, (self.width()) * progress, self.height() * .5)
        painter.drawRect(barRect)

        outline = QtCore.QRect(1, self.height() * .25, (self.width())-2, self.height() * .5)
        painter.setBrush(QtGui.QColor(0,0,0,0))
        painter.setPen(QtGui.QColor(0,0,0,255))
        painter.drawRect(outline)
项目:PandwaRF    作者:ComThings    | 项目源码 | 文件源码
def _draw_graph(self):
        if self._graph is None:
            self._new_graph()
        elif self._graph.size() != self.size():
            self._new_graph()

        painter = QtGui.QPainter(self._graph)
        try:
            painter.setRenderHint(QtGui.QPainter.Antialiasing)
            painter.fillRect(0, 0, self._graph.width(), self._graph.height(), QtGui.QColor(0, 0, 0, 10))

            if self._frame:
                frequency_axis, rssi_values = self._frame

                path_now = QtGui.QPainterPath()
                path_max = QtGui.QPainterPath()

                bins = range(len(frequency_axis))
                x_axis = self._hz_to_x(frequency_axis)
                y_now = self._dbm_to_y(rssi_values)
                y_max = self._dbm_to_y(numpy.amax(self._persisted_frames, axis=0))

                # TODO: Wrapped Numpy types with float() to support old (<1.0) PySide API in Ubuntu 10.10
                path_now.moveTo(float(x_axis[0]), float(y_now[0]))
                for i in bins:
                    path_now.lineTo(float(x_axis[i]), float(y_now[i]))

                # TODO: Wrapped Numpy types with float() to support old (<1.0) PySide API in Ubuntu 10.10
                path_max.moveTo(float(x_axis[0]), float(y_max[0]))
                for i in bins:
                    path_max.lineTo(float(x_axis[i]), float(y_max[i]))

                painter.setPen(Qt.white)
                painter.drawPath(path_now)
                self._path_max = path_max
        finally:
            painter.end()
项目:PandwaRF    作者:ComThings    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:ebbbe    作者:EarToEarOak    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)

        colour = self._colour
        if not self._lit:
            colour = self._colour.darker(300)
        painter.setPen(QPen(Qt.black, 1))
        painter.setBrush(QBrush(colour))

        rect = event.rect()
        radius = min(rect.width(), rect.height()) / 3
        painter.drawEllipse(rect.center(), radius, radius)

        painter.end()