当前位置: 首页>>代码示例>>Python>>正文


Python QPainter.begin方法代码示例

本文整理汇总了Python中PySide.QtGui.QPainter.begin方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.begin方法的具体用法?Python QPainter.begin怎么用?Python QPainter.begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QPainter的用法示例。


在下文中一共展示了QPainter.begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def paintEvent(self, e):
        painter = QPainter()
        painter.begin(self)
        
        width = self.width()
        height = self.height()
        
        #Blank out the world
        painter.fillRect(0, 0, width, height, Qt.white)

        #Compute width/height of the columns and rows
        
        #Reserve pixels for the grid lines
        colWidth = (width - (self._NUM_COLS - 1) * self._GRID_SIZE) / self._NUM_COLS
        rowHeight = (height - (self._NUM_ROWS - 1) * self._GRID_SIZE) / self._NUM_ROWS
        
        colWidth = max(1, colWidth)
        rowHeight = max(1, rowHeight)

        #Perform drawing operations for world rendering
        self._drawGrid(width, height, colWidth, rowHeight, painter)
        self._drawObstacles(colWidth, rowHeight, painter)
        if self._drawVisited:
            self._drawVisitedCells(colWidth, rowHeight, painter)
        if self._drawActive:
            self._drawActiveCells(colWidth, rowHeight, painter)
        self._drawStartAndEndCells(colWidth, rowHeight, painter)
        self._drawCurrentCell(colWidth, rowHeight, painter)
        if self._drawCheapestPath:
            self._drawPath(colWidth, rowHeight, painter)
        
        painter.end()
开发者ID:tansir1,项目名称:ReverseAStar,代码行数:34,代码来源:gui.py

示例2: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.save()
        self.rect = painter.viewport()
        self.rect.adjust(0, 0, -1, -1)
        painter.drawRect(QRectF(self.rect))
        
        self.prj.setupPrism(self.rect.height(), 68)
        self.prj.setupProjectionMatrix(self.alef, self.bet)
        
        # draw the prism
        self.drawCubick(painter, [0, 0, 0], 63, 16)
        
        mineCube = self.parent.presenter.mineCube
        for y in range(len(mineCube)):
            for z in range(len(mineCube[0])):
                for x in range(len(mineCube[0][0])):
                    if mineCube[y][z][x] in self.parent.selectedMinerals.list_:
                        colo = self.parent.selectedMinerals.\
                                                     getColor(mineCube[y][z][x])
                        self.drawCubick(painter, [x, y, z], color=colo)

        self.drawSliceCursor(painter, self.parent.presenter.elevation)

        painter.restore()
        painter.end()
        del painter
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:30,代码来源:__init__.py

示例3: drawIconWithShadow

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def drawIconWithShadow(icon, rect, p, iconMode, radius, color, offset):
        cache = QPixmap()
        pixmapName = "icon {0} {1} {2}".format(icon.cacheKey(), iconMode, rect.height())

        if not QPixmapCache.find(pixmapName, cache):
            px = icon.pixmap(rect.size())
            cache = QPixmap(px.size() + QSize(radius * 2, radius * 2))
            cache.fill(Qt.transparent)

            cachePainter = QPainter(cache)
            if iconMode == QIcon.Disabled:
                im = px.toImage().convertToFormat(QImage.Format_ARGB32)
                for y in range(im.height()):
                    scanLine = im.scanLine(y)
                    for x in range(im.width()):
                        pixel = scanLine
                        intensity = qGray(pixel)
                        scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel))
                        scanLine += 1
                px = QPixmap.fromImage(im)

            # Draw shadow
            tmp = QImage(px.size() + QSize(radius * 2, radius * 2 + 1), QImage.Format_ARGB32_Premultiplied)
            tmp.fill(Qt.transparent)

            tmpPainter = QPainter(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_Source)
            tmpPainter.drawPixmap(QPoint(radius, radius), px)
            tmpPainter.end()

            # blur the alpha channel
            blurred = QImage(tmp.size(), QImage.Format_ARGB32_Premultiplied)
            blurred.fill(Qt.transparent)
            blurPainter = QPainter(blurred)
            # todo : blur image
            blurPainter.end()

            tmp = blurred

            # blacken the image
            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            # draw the blurred drop shadow...
            cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp)

            # Draw the actual pixmap...
            cachePainter.drawPixmap(QPoint(radius, radius) + offset, px)
            QPixmapCache.insert(pixmapName, cache)

        targetRect = cache.rect()
        targetRect.moveCenter(rect.center())
        p.drawPixmap(targetRect.topLeft() - offset, cache)
开发者ID:nichollyn,项目名称:libspark,代码行数:62,代码来源:stylehelper.py

示例4: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
 def paintEvent(self, event):
     painter = QPainter()
     painter.begin(self)
     painter.setRenderHint(QPainter.HighQualityAntialiasing)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.setRenderHint(QPainter.SmoothPixmapTransform)
     # change the look for on/off
     if self.isChecked():
         # blue fill
         brush = QBrush(self.color1)
         painter.setBrush(brush)
         painter.drawRoundedRect(0, 7, self.width() - 2, self.height() - 15, self.height() / 2 - 10,
                                 self.height() / 2)
         brush = QBrush(self.lighter(self.color1))
         painter.setBrush(brush)
         painter.drawEllipse(self.width() - self.height(), 0, self.height(), self.height())
     else:
         # gray fill
         brush = QBrush(self.color2)
         painter.setBrush(brush)
         painter.drawRoundedRect(1, 7, self.width() - 3, self.height() - 15, self.height() / 2 - 10,
                                 self.height() / 2)
         brush = QBrush(QColor(100, 100, 100))
         painter.setBrush(brush)
         painter.drawEllipse(0, 0, self.height(), self.height())
     painter.end()
开发者ID:ethanhs,项目名称:material,代码行数:28,代码来源:material.py

示例5: paint

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
 def paint(self, painter, option, widget=None):
     painter_inverted = QPainter()
     brect= QGraphicsProxyWidget.boundingRect(self)
     invertedColor = QImage(brect.width(),brect.height(),QImage.Format_RGB32)
     painter_inverted.begin(invertedColor)
     QGraphicsProxyWidget.paint(self,painter_inverted, option, widget)
     painter_inverted.end()
     painter.drawImage(0,0,invertedColor.rgbSwapped())
开发者ID:coderakki,项目名称:Media-player,代码行数:10,代码来源:try.py

示例6: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def paintEvent(self, event):
        text = []
        text.append(['{0}; {1}'.format(self.parent.chunkData['X'], self.parent.chunkData['Y']), Qt.black])
        if self.parent.chunkData[14] > 0:
            text.append(['Gold = {0}'.format(self.parent.chunkData[14]), Qt.yellow])
        else:
            text.append(['', Qt.yellow])
        if self.parent.chunkData[15] > 0:
            text.append(['Iron = {0}'.format(self.parent.chunkData[15]), Qt.red])
        else:
            text.append(['', Qt.red])
        if self.parent.chunkData[56] > 0:
            text.append(['Diamond = {0}'.format(self.parent.chunkData[56]), Qt.cyan])
        else:
            text.append(['', Qt.cyan])
        if self.parent.chunkData[73] > 0:
            text.append(['Redstone = {0}'.format(self.parent.chunkData[73]), Qt.magenta])
        else:
            text.append(['', Qt.magenta])
        if self.parent.chunkData[49] > 0:
            text.append(['Obsidian = {0}'.format(self.parent.chunkData[49]), Qt.darkYellow])
        else:
            text.append(['', Qt.darkYellow])
        if self.parent.chunkData[21] > 0:
            text.append(['Lazurit = {0}'.format(self.parent.chunkData[21]), Qt.darkBlue])
        else:
            text.append(['', Qt.darkBlue])

        painter = QPainter()
        painter.begin(self)

        painter.drawRect(self.parent.leftMargin, self.parent.topMargin,
                         self.edgeLen, self.edgeLen)

        cX = self.parent.leftMargin + self.parent.vsepara
        cY = self.parent.topMargin + self.parent.hsepara

        alig = Qt.AlignCenter
        i = 0
        fontik = painter.font()
        for t in text:
            if i > 0:
                alig = Qt.AlignLeft
            painter.setPen(t[1])
            if i == 2:
                fontik.setUnderline(True)
            else:
                fontik.setUnderline(False)
            painter.setFont(fontik)
            painter.drawText(cX, cY, self.tBoxWidth, self.tBoxHeight, alig, t[0])
            cY += self.lineSpacing
            i += 1
            

        painter.end()
        del painter
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:58,代码来源:OverviewTest01.py

示例7: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
	def paintEvent(self, event):
		painter = QPainter()

		painter.begin(self)

		self.theme.render(painter, "kdiamond-" + self.color)
		if self.selected:
			self.theme.render(painter, "kdiamond-selection")

		painter.end()
开发者ID:omartinak,项目名称:flow,代码行数:12,代码来源:diamond.py

示例8: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
 def paintEvent(self, e):
     ''' overwrite paintEvent in order to also redraw points (indicating
     electrode positions) and their link to added plots
     
     this is necessary to get smooth animation if plots are dragged around
     '''
     super(DragWindow, self).paintEvent(e)
     qp = QPainter()
     qp.begin(self)
     self.drawPoints(qp)
     qp.end()
开发者ID:Yakisoba007,项目名称:PyTrigno,代码行数:13,代码来源:plotter.py

示例9: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def paintEvent(self, evt):
        # print 'paint', self.color, self.text(), self.width(), self.height(), evt.rect().width()
        qp = QPainter()
        qp.begin(self)
        qp.setBrush(QColor('#{}'.format(self.color[:-2])))
        qp.drawRect(0, 0, self.width(), self.height())
        qp.end()

        qp.begin(self)
        qp.setPen(self._get_text_color())
        qp.drawText(evt.rect(), QtCore.Qt.AlignCenter, self.text())
        qp.end()
开发者ID:OSUPychron,项目名称:pychron,代码行数:14,代码来源:label_editor.py

示例10: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def paintEvent(self, event):
        cX = self.parent.leftMargin + self.scaleMarkLen
        cY = self.parent.topMargin + self.scaleMarkLen
        worldX = self.parent.chunkX*16
        worldZ = self.parent.chunkZ*16
        painter = QPainter()
        path = QPainterPath()
        painter.begin(self)
        painter.save()
        #painter.setFont(QFont('Arial Narrow', 8)) #QFont.Bold
        # draw scale
        x = cX
        y = cY
        painter.rotate(-90)
        for i in range(16):
            fr = QRectF(-y, x, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            painter.drawRect(fr)
            #fr = QRectF(-y - 16*self.edgeLen - self.scaleMarkLen, x, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            x += self.edgeLen
        painter.rotate(90)

        x = self.parent.leftMargin
        y = cY
        for i in range(16):
            fr = QRectF(x, y, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            painter.drawRect(fr)
            #fr = QRectF(x + self.scaleMarkLen + 16*self.edgeLen, y, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            y += self.edgeLen

        x = cX
        y = cY
        for i in range(16):
            for j in range(16):
                path.addRect(x, y, self.edgeLen, self.edgeLen)
                fr = QRectF(x, y, self.edgeLen, self.edgeLen)
                #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
                x += self.edgeLen
            x = cX
            y += self.edgeLen

        painter.drawPath(path)

        painter.restore()
        painter.end()
        del painter
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:53,代码来源:SliceTest01.py

示例11: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def paintEvent(self, event):
        qp = QPainter()
        qp.begin(self)
        c = QColor()
        c.setNamedColor(self._window_bgcolor)

        h, s, l, a = c.getHsl()
        c.setHsl(h, s, 100, a)

        pen = QPen(c, 8, QtCore.Qt.SolidLine)
        qp.setPen(pen)

        qp.drawRoundedRect(event.rect(), 12, 12)
        qp.end()
开发者ID:OSUPychron,项目名称:pychron,代码行数:16,代码来源:notification_widget.py

示例12: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def paintEvent(self, event):
        QPushButton.paintEvent(self, event)

        qp = QPainter()
        qp.begin(self)

        font = qp.font()
        font.setPixelSize(8)
        font.setWeight(QFont.Normal)
        qp.setFont(font)

        qp.drawText(event.rect().translated(1, 1), str(self._atomic_number))

        qp.end()
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:16,代码来源:periodictable.py

示例13: saveAsPDF

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def saveAsPDF(self):
        '''Save plot as a PDF'''
        if not self.control.hasPlot:
            error.showMessage('Cannot save.. there is no data to save yet')
            return
        filter = 'PDF Documents (*.pdf);;All (*)'
        d = '' if self.pdfName is None else self.pdfName
        s = QFileDialog.getSaveFileName(self, 'PDF File Name',
                                              d, filter)
        # Continue unless the user hit cancel
        if not s[0]:
            return
        self.pdfName = s[0]

        # Set up the PDF printer
        printer = QPrinter()
        printer.setOutputFormat(QPrinter.PdfFormat)
        printer.setOrientation(QPrinter.Landscape)
        printer.setOutputFileName(self.pdfName)
        printer.setCreator('RAPID')

        # Send to the plot for printing
        p = QPainter()
        p.begin(printer)
        x, y = self.plot.calculatedData()
        plt = pgplot(x, y,
                     antialias=True,
                     connect='all',
                     pen={'color': 'b', 'width': 0})
        plt.setLabel('bottom', "Frequency (Wavenumbers, cm<sup>-1</sup>)")
        plt.getAxis('bottom').setPen('k')
        plt.setLabel('left', "Intensity (Normalized)")
        plt.getAxis('left').setPen('k')
        plt.setYRange(0, 1.1, padding=0)
        plt.invertX(self.plot.reversed)
        plt.setBackground('w')  # White

        # The raw (experimental) data, if any
        if self.plot.rawData is not None:
            data = self.plot.getRawData()
            x, y = data[:,0], data[:,1]
            curve2 = PlotCurveItem(x, y,
                                   antialias=True,
                                   connect='all',
                                   pen={'color': 'g', 'width': 0})
            plt.addItem(curve2)
        plt.render(p)
        p.end()
开发者ID:jensengrouppsu,项目名称:rapid,代码行数:50,代码来源:mainwindow.py

示例14: createPixmap

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
    def createPixmap(self):
        """Creates the pixmap shown when this label is dragged."""
        font_metric = QFontMetrics(QFont())
        text_size = font_metric.size(Qt.TextSingleLine, self.text)
        image = QImage(text_size.width() + 4, text_size.height() + 4,
            QImage.Format_ARGB32_Premultiplied)
        image.fill(qRgba(240, 240, 120, 255))

        painter = QPainter()
        painter.begin(image)
        painter.setFont(QFont())
        painter.setBrush(Qt.black)
        painter.drawText(QRect(QPoint(2, 2), text_size), Qt.AlignCenter,
            self.text)
        painter.end()
        return image
开发者ID:LLNL,项目名称:boxfish,代码行数:18,代码来源:GUIUtils.py

示例15: draw_uvs

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import begin [as 别名]
 def draw_uvs(self):
     self.img = QPixmap(QSize(self.w, self.h))
     pen = QPen()
     pen.setWidth(int(self.pen_w.text()))
     pen.setBrush(QBrush(Qt.white))
     pen.setColor(QColor('white'))
     painter = QPainter()
     painter.begin(self.img)
     painter.setPen(pen)
     coords = self.get_coords()
     for face in coords:
         for n in xrange(len(face) - 1):
             print face[n][0], face[n][1], face[n + 1][0], face[n + 1][1]
             painter.drawLine(face[n][0], face[n][1], face[n + 1][0], face[n + 1][1])
     painter.end()
     self.view.scene().addPixmap(self.img)
开发者ID:Schlechtwetterfront,项目名称:mshsuite,代码行数:18,代码来源:model_dialogs.py


注:本文中的PySide.QtGui.QPainter.begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。