當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QPainter方法代碼示例

本文整理匯總了Python中PyQt5.QtGui.QPainter方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QPainter方法的具體用法?Python QtGui.QPainter怎麽用?Python QtGui.QPainter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.QPainter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: paintEvent

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def paintEvent(self, event):
        QtWidgets.QFrame.paintEvent(self, event)
        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        painter.setPen(Qt.NoPen)
        # Draw the Pie
        rwidth = int(min([self.width(), self.height()]) - 2)
        x = int((self.width() / 2) - (rwidth / 2))
        y = int((self.height() / 2) - (rwidth / 2))
        rect = QtCore.QRect(x, y, rwidth, rwidth)
        angle1 = 0
        for i in range(len(self.data)):
            angle2 = angle1 + (3.6 * self.data[i])
            painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)]))
            painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16)
            angle1 = angle2
        # Draw the remainer (background)
        angle2 = 360
        painter.setBrush(QtGui.QBrush(self.bgcolor))
        painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16)
        painter.end() 
開發者ID:pkkid,項目名稱:pkmeter,代碼行數:24,代碼來源:pkcharts.py

示例2: _paint_frame

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def _paint_frame(self, event):
        if self.bgimage:
            pixmap = self._build_pixmap(self.bgimage)
            # Check we need to resize the bgimage
            if self.bgsize:
                bgsize = self.bgsize
                if self.bgsize == 'fit':
                    bgsize = self.size()
                pixmap = pixmap.scaled(bgsize, Qt.KeepAspectRatio, Qt.SmoothTransformation)
            # Calculate the x,y position
            x,y = self.bgpos
            if self.bgpos:
                if x == 'left': x = 0
                elif x == 'center': x = (self.width() / 2) - (pixmap.width() / 2)
                elif x == 'right': x = self.width() - pixmap.width()
                if y == 'top': y = 0
                elif y == 'center': y = (self.height() / 2) - (pixmap.height() / 2)
                elif y == 'bottom': y = self.height() - pixmap.height()
            # Draw the pixmap
            painter = QtGui.QPainter(self)
            painter.setOpacity(self.bgopacity)
            painter.drawPixmap(int(x), int(y), pixmap) 
開發者ID:pkkid,項目名稱:pkmeter,代碼行數:24,代碼來源:pkmixins.py

示例3: draw

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def draw(self, refresh=False):
        if self.dataModel.getOffset() in self.Paints:
            self.refresh = False
            self.qpix = QtGui.QPixmap(self.Paints[self.dataModel.getOffset()])
            self.drawAdditionals()
            return

        if self.refresh or refresh:
            qp = QtGui.QPainter()
            qp.begin(self.qpix)

            self.drawTextMode(qp)
            self.refresh = False
            qp.end()

        #        self.Paints[self.dataModel.getOffset()] = QtGui.QPixmap(self.qpix)
        self.drawAdditionals() 
開發者ID:amimo,項目名稱:dcc,代碼行數:19,代碼來源:DisasmViewMode.py

示例4: drawAdditionals

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def drawAdditionals(self):
        self.newPix = self._getNewPixmap(self.width, self.height + self.SPACER)
        qp = QtGui.QPainter()
        qp.begin(self.newPix)
        qp.setWindow(-50, 0, self.COLUMNS * self.fontWidth, self.ROWS * self.fontHeight)

        qp.drawPixmap(0, 0, self.qpix)

        # self.transformationEngine.decorateText()

        # highlight selected text
        self.selector.highlightText()

        # draw other selections
        self.selector.drawSelections(qp)

        # draw our cursor
        self.drawCursor(qp)

        self.drawBranch(qp)
        self.drawSelected(qp)

        qp.end() 
開發者ID:amimo,項目名稱:dcc,代碼行數:25,代碼來源:DisasmViewMode.py

示例5: draw

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def draw(self, refresh=False):
        if self.dataModel.getOffset() in self.Paints:
            self.refresh = False
            self.qpix = QtGui.QPixmap(self.Paints[self.dataModel.getOffset()])
            self.drawAdditionals()
            return

        if self.refresh or refresh:
            qp = QtGui.QPainter()
            qp.begin(self.qpix)
            self.drawTextMode(qp)
            self.refresh = False
            qp.end()

        self.drawAdditionals() 
開發者ID:amimo,項目名稱:dcc,代碼行數:17,代碼來源:SourceViewMode.py

示例6: drawAdditionals

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def drawAdditionals(self):
        self.newPix = self._getNewPixmap(self.width, self.height + self.SPACER)
        qp = QtGui.QPainter()
        qp.begin(self.newPix)
        qp.setWindow(-50, 0, self.COLUMNS * self.fontWidth, self.ROWS * self.fontHeight)

        qp.drawPixmap(0, 0, self.qpix)

        # self.transformationEngine.decorateText()

        # highlight selected text
        self.selector.highlightText()

        # draw other selections
        self.selector.drawSelections(qp)

        # draw our cursor
        self.drawCursor(qp)
        self.drawLine(qp)

        qp.end() 
開發者ID:amimo,項目名稱:dcc,代碼行數:23,代碼來源:SourceViewMode.py

示例7: drawAdditionals

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def drawAdditionals(self):
        self.newPix = self._getNewPixmap(self.width, self.height + self.SPACER)
        qp = QtGui.QPainter()
        qp.begin(self.newPix)
        qp.drawPixmap(0, 0, self.qpix)

        # self.transformationEngine.decorateText()

        # highlight selected text
        self.selector.highlightText()

        # draw other selections
        self.selector.drawSelections(qp)

        # draw our cursor
        self.drawCursor(qp)

        # draw dword lines
        for i in range(self.COLUMNS // 4)[1:]:
            xw = i * 4 * 3 * self.fontWidth - 4
            qp.setPen(QtGui.QColor(0, 255, 0))
            qp.drawLine(xw, 0, xw, self.ROWS * self.fontHeight)

        qp.end() 
開發者ID:amimo,項目名稱:dcc,代碼行數:26,代碼來源:HexViewMode.py

示例8: draw

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def draw(self):
        qp = QtGui.QPainter()

        offset = self.viewMode.getPageOffset()
        columns, rows = self.viewMode.getGeometry()

        qp.begin(self.qpix)
        qp.fillRect(0, 0, self.width, self.height, self.backgroundBrush)
        qp.setPen(self.textPen)
        qp.setFont(self.font)

        for i in range(rows):
            s = '{0:08x}'.format(offset)
            qp.drawText(0 + 5, (i + 1) * self.fontHeight, s)
            columns = self.viewMode.getColumnsbyRow(i)
            offset += columns

        qp.end() 
開發者ID:amimo,項目名稱:dcc,代碼行數:20,代碼來源:Banners.py

示例9: drawAdditionals

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def drawAdditionals(self):
        self.newPix = self._getNewPixmap(self.width, self.height + self.SPACER)
        qp = QtGui.QPainter()
        qp.begin(self.newPix)
        qp.drawPixmap(0, 0, self.qpix)

        # self.transformationEngine.decorateText()

        # highlight selected text
        self.selector.highlightText()

        # draw other selections
        self.selector.drawSelections(qp)

        # draw our cursor
        self.drawCursor(qp)
        qp.end() 
開發者ID:amimo,項目名稱:dcc,代碼行數:19,代碼來源:BinViewMode.py

示例10: draw

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def draw(self, refresh=False, row=0, howMany=0):
        if self.dataModel.getOffset() in self.Paints:
            self.refresh = False
            self.qpix = QtGui.QPixmap(self.Paints[self.dataModel.getOffset()])
            self.drawAdditionals()
            return

        if self.refresh or refresh:
            qp = QtGui.QPainter()
            qp.begin(self.qpix)
            start = time()
            if not howMany:
                howMany = self.ROWS

            self.drawTextMode(qp, row=row, howMany=howMany)
            end = time() - start
            log.debug('draw Time ' + str(end))
            self.refresh = False
            qp.end()

        #        self.Paints[self.dataModel.getOffset()] = QtGui.QPixmap(self.qpix)
        self.drawAdditionals() 
開發者ID:amimo,項目名稱:dcc,代碼行數:24,代碼來源:BinViewMode.py

示例11: drawBackground

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def drawBackground(self, pixmap):
        """Draw background in pixmap.
        """
        w, h = pixmap.width(), pixmap.height()
        mode = self.__bgModes[self.bgCBox.currentIndex()]
        source = QPixmap(pixmap)
        painter = QtGui.QPainter(pixmap)
        if mode == self.BG_COLOR:
            painter.fillRect(0, 0, w, h, self.bgColor)
        if mode == self.BG_TRANSPARENT or mode == self.BG_IMAGE or mode == self.BG_INPUT:
            painter.drawPixmap(0, 0, common.checkerboard(pixmap.size()))
        if mode == self.BG_IMAGE and self.bgPath:
            bgPixmap = QPixmap(self.bgPath)
            if not bgPixmap.isNull():
                bgPixmap = bgPixmap.scaled(w, h, QtCore.Qt.IgnoreAspectRatio)
                painter.drawPixmap(0, 0, bgPixmap)
        if mode == self.BG_INPUT:
            painter.drawPixmap(0, 0, source) 
開發者ID:xsyann,項目名稱:detection,代碼行數:20,代碼來源:detection.py

示例12: paintEvent

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def paintEvent(self, evt: QPaintEvent):
			if not self.psuedo_line:
				self.psuedo_line = 1
				return

			x = y = 0
			y += self.fontMetrics().ascent()
			painter = QPainter(self)

			self.draw_text_n_outline(
				painter,
				x,
				y + config.outline_top_padding - config.outline_bottom_padding,
				config.outline_thickness,
				config.outline_blur,
				text = self.line
				) 
開發者ID:oltodosel,項目名稱:interSubs,代碼行數:19,代碼來源:interSubs.py

示例13: highligting

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def highligting(self, color, underline_width):
		color = QColor(color)
		color = QColor(color.red(), color.green(), color.blue(), 200)
		painter = QPainter(self)

		if config.hover_underline:
			font_metrics = QFontMetrics(self.font())
			text_width = font_metrics.width(self.word)
			text_height = font_metrics.height()

			brush = QBrush(color)
			pen = QPen(brush, underline_width, Qt.SolidLine, Qt.RoundCap)
			painter.setPen(pen)
			if not self.skip:
				painter.drawLine(0, text_height - underline_width, text_width, text_height - underline_width)

		if config.hover_hightlight:
			x = y = 0
			y += self.fontMetrics().ascent()

			painter.setPen(color)
			painter.drawText(x, y + config.outline_top_padding - config.outline_bottom_padding, self.word) 
開發者ID:oltodosel,項目名稱:interSubs,代碼行數:24,代碼來源:interSubs.py

示例14: paintEvent

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def paintEvent(self, e):
        qp = QtGui.QPainter()
        qp.begin(self)
        qp.setOpacity(1)

        offsetLeft = self.offsetWindow_h + self.Banners.getLeftOffset()
        offsetBottom   = self.offsetWindow_v + self.Banners.getTopOffset()

        #self.viewMode.draw2(qp, refresh=True)
        #start = time()
        qp.drawPixmap(offsetLeft, offsetBottom, self.viewMode.getPixmap())
        #print 'Draw ' + str(time() - start)

        self.Banners.draw(qp, self.offsetWindow_h, self.offsetWindow_v, self.size().height())

      #  qp.drawPixmap(self.offsetWindow_h, self.size().height() - 50, self.banner.getPixmap())

       # qp.drawPixmap(20, 0, self.filebanner.getPixmap())
        qp.end() 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:21,代碼來源:qiew.py

示例15: draw

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QPainter [as 別名]
def draw(self, refresh=False):
        if self.dataModel.getOffset() in self.Paints:
            self.refresh = False
            self.qpix = QtGui.QPixmap(self.Paints[self.dataModel.getOffset()])
            #print 'hit'
            self.drawAdditionals()
            return

        if self.refresh or refresh:
            qp = QtGui.QPainter()
            qp.begin(self.qpix)
            # viewport
            #qp.fillRect(0, 0, self.COLUMNS * self.fontWidth,  self.ROWS * self.fontHeight, self.backgroundBrush)

            #start = time()
            self.drawTextMode(qp)
            #end = time() - start
            #print 'Time ' + str(end)
            self.refresh = False
            qp.end()

#        self.Paints[self.dataModel.getOffset()] = QtGui.QPixmap(self.qpix)
        self.drawAdditionals() 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:25,代碼來源:DisasmViewMode.py


注:本文中的PyQt5.QtGui.QPainter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。