Python PyQt5.QtGui.QPainter() Examples

The following are 30 code examples of PyQt5.QtGui.QPainter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .
Example #1
Source File: pkmixins.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
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) 
Example #2
Source File: interSubs.py    From interSubs with MIT License 7 votes vote down vote up
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) 
Example #3
Source File: items.py    From Miyamoto with GNU General Public License v3.0 6 votes vote down vote up
def paint(self, painter, option, widget):
        """
        Paints the path
        """
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        painter.setClipRect(option.exposedRect)

        if self.isSelected():
            painter.setBrush(QtGui.QBrush(globals.theme.color('path_fill_s')))
            painter.setPen(QtGui.QPen(globals.theme.color('path_lines_s'), 1 / 24 * globals.TileWidth))
        else:
            painter.setBrush(QtGui.QBrush(globals.theme.color('path_fill')))
            painter.setPen(QtGui.QPen(globals.theme.color('path_lines'), 1 / 24 * globals.TileWidth))
        painter.drawRoundedRect(self.RoundedRect, 4, 4)

        painter.setFont(self.font)
        margin = globals.TileWidth / 10
        painter.drawText(QtCore.QRectF(margin, margin, globals.TileWidth / 2 - margin, globals.TileWidth / 2 - margin), Qt.AlignCenter,
                         str(self.pathid))
        painter.drawText(QtCore.QRectF(margin, globals.TileWidth / 2, globals.TileWidth / 2 - margin, globals.TileWidth / 2 - margin),
                         Qt.AlignCenter, str(self.nodeid)) 
Example #4
Source File: Banners.py    From dcc with Apache License 2.0 6 votes vote down vote up
def draw(self):
        # i don't really like this in terms of arhitecture. We have
        # artificially introduced getHeaderInfo() in Views. Then we had one top
        # banner implemented per plugin. I will think to a better solution

        qp = QtGui.QPainter()
        qp.begin(self.qpix)

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

        cemu = ConsoleEmulator(qp, self.height // self.fontHeight, self.width // self.fontWidth)

        cemu.writeAt(1, 0, 'FileAddr')

        offset = 11

        text = self.viewMode.getHeaderInfo()

        cemu.writeAt(offset, 0, text)

        qp.end() 
Example #5
Source File: HexViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #6
Source File: Banners.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #7
Source File: SourceViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #8
Source File: pkcharts.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def paintEvent(self, event):
        if not self.data: return
        QtWidgets.QFrame.paintEvent(self, event)
        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        # Draw background
        painter.setBrush(QtGui.QBrush(self.bgcolor))
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(self.contentsRect(), 2, 2)
        # Draw the bars
        barwidth = (self.width() - 4) / len(self.data)
        for i in range(len(self.data)):
            barheight = int(self.height() * (self.data[i] / 100))
            baroffset = i * barwidth + 2
            painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)]))
            painter.drawRoundedRect(baroffset, self.height()-barheight, barwidth, barheight, 1, 1)
        painter.end() 
Example #9
Source File: DisasmViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #10
Source File: BinViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #11
Source File: BinViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #12
Source File: SourceViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #13
Source File: DisasmViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
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() 
Example #14
Source File: pkcharts.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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() 
Example #15
Source File: detection.py    From detection with GNU General Public License v2.0 6 votes vote down vote up
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) 
Example #16
Source File: interSubs.py    From interSubs with MIT License 6 votes vote down vote up
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
				) 
Example #17
Source File: qiew.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
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() 
Example #18
Source File: DisasmViewMode.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
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() 
Example #19
Source File: HexViewMode.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
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() 
Example #20
Source File: Banners.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
def draw(self):
        # i don't really like this in terms of arhitecture. We have
        # artificially introduced getHeaderInfo() in Views. Then we had one top
        # banner implemented per plugin. I will think to a better solution

        qp = QtGui.QPainter()
        qp.begin(self.qpix)

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

        cemu = ConsoleEmulator(qp, self.height//self.fontHeight, self.width//self.fontWidth)

        cemu.writeAt(1, 0, 'FileAddr')

        offset = 11

        text = self.viewMode.getHeaderInfo()

        cemu.writeAt(offset, 0, text)
        
        qp.end() 
Example #21
Source File: BinViewMode.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
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() 
Example #22
Source File: bootsector.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
def draw(self):
        qp = QtGui.QPainter()

        displayType = self.plugin.getAddressMode()

        if displayType == 'MemAddr':
            offset = 0x7c00 + self.viewMode.getPageOffset()
        else:
            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() 
Example #23
Source File: traywidget.py    From kawaii-player with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent=None, ui_widget=None, home=None, window=None, logr=None):
        global ui, MainWindow, logger
        QtWidgets.QSystemTrayIcon.__init__(self, parent)
        ui = parent
        MainWindow = window
        logger = logr
        icon_img = os.path.join(home, 'src', 'tray.png')
        self.right_menu = RightClickMenuIndicator(ui_widget=ui_widget,
                                                  window=window, logr=logr)
        self.setContextMenu(self.right_menu)

        self.activated.connect(self.onTrayIconActivated)
        self.p = QtGui.QPixmap(24, 24)
        self.p.fill(QtGui.QColor("transparent"))
        painter	= QtGui.QPainter(self.p)
        if os.path.exists(icon_img):
            self.setIcon(QtGui.QIcon(icon_img))
        else:
            self.setIcon(QtGui.QIcon(""))
        self.full_scr = 1
        del painter 
Example #24
Source File: tetris_game.py    From tetris_game with MIT License 6 votes vote down vote up
def paintEvent(self, event):
        painter = QPainter(self)

        # Draw backboard
        for x in range(BOARD_DATA.width):
            for y in range(BOARD_DATA.height):
                val = BOARD_DATA.getValue(x, y)
                drawSquare(painter, x * self.gridSize, y * self.gridSize, val, self.gridSize)

        # Draw current shape
        for x, y in BOARD_DATA.getCurrentShapeCoord():
            val = BOARD_DATA.currentShape.shape
            drawSquare(painter, x * self.gridSize, y * self.gridSize, val, self.gridSize)

        # Draw a border
        painter.setPen(QColor(0x777777))
        painter.drawLine(self.width()-1, 0, self.width()-1, self.height())
        painter.setPen(QColor(0xCCCCCC))
        painter.drawLine(self.width(), 0, self.width(), self.height()) 
Example #25
Source File: mainWindow.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, event):
        if self.count():
            QtWidgets.QTabWidget.paintEvent(self, event)
        else:
            painter = QtGui.QPainter(self)
            rect = event.rect()
            image = QtGui.QImage("images/pychemqt.png")
            rectImage = QtCore.QRect(25, rect.center().y()-50, 100, 100)
            painter.drawImage(rectImage, image)
            txt = QtWidgets.QApplication.translate(
                "pychemqt", """Welcome to pychemqt,
a software for simulating Chemical Engineering units operations,

Copyright © 2012 Juan José Gómez Romera (jjgomera)
Licenced with GPL.v3
This software is distributed in the hope that it will be useful,
but without any warranty, it is provided "as is" without warranty of any kind

You can start by creating a new project or opening an existing project.""",
                None)
            rect.setLeft(150)
            painter.drawText(rect, QtCore.Qt.AlignVCenter, txt) 
Example #26
Source File: mainWindow.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def savePFDImage(self):
        if self.filename[self.idTab]:
            dir = os.path.dirname(str(self.filename[self.idTab]))
        else:
            dir = "."
        fname = QtWidgets.QFileDialog.getSaveFileName(
            None,
            QtWidgets.QApplication.translate("pychemqt", "Save PFD as image"),
            dir, "Portable Network Graphics (*.png)")[0]
        if fname:
            rect = self.currentScene.sceneRect()
            img = QtGui.QImage(
                rect.width(), rect.height(),
                QtGui.QImage.Format_ARGB32_Premultiplied)
            p = QtGui.QPainter(img)
            self.currentScene.render(p)
            p.end()
            img.save(fname) 
Example #27
Source File: videoservice.py    From vidcutter with GNU General Public License v3.0 6 votes vote down vote up
def captureFrame(settings: QSettings, source: str, frametime: str, thumbsize: QSize=None,
                     external: bool=False) -> QPixmap:
        if thumbsize is None:
            thumbsize = VideoService.config.thumbnails['INDEX']
        capres = QPixmap()
        img = QTemporaryFile(os.path.join(QDir.tempPath(), 'XXXXXX.jpg'))
        if img.open():
            imagecap = img.fileName()
            cmd = VideoService.findBackends(settings).ffmpeg
            tsize = '{0:d}x{1:d}'.format(thumbsize.width(), thumbsize.height())
            args = '-hide_banner -ss {frametime} -i "{source}" -vframes 1 -s {tsize} -y "{imagecap}"'.format(**locals())
            proc = VideoService.initProc()
            if proc.state() == QProcess.NotRunning:
                proc.start(cmd, shlex.split(args))
                proc.waitForFinished(-1)
                if proc.exitStatus() == QProcess.NormalExit and proc.exitCode() == 0:
                    capres = QPixmap(imagecap, 'JPG')
                if external:
                    painter = QPainter(capres)
                    painter.drawPixmap(0, 0, QPixmap(':/images/external.png', 'PNG'))
                    painter.end()
        img.remove()
        return capres

    # noinspection PyBroadException 
Example #28
Source File: BinViewMode.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
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()])
            #print 'hit'
            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
            #print 'Time ' + str(end)
            self.refresh = False
            qp.end()

#        self.Paints[self.dataModel.getOffset()] = QtGui.QPixmap(self.qpix)
        self.drawAdditionals() 
Example #29
Source File: globalmapwidget.py    From PyPipboyApp with GNU General Public License v3.0 5 votes vote down vote up
def _getPixmap_(self):
        p = self.imageFactory.getPixmap(self.imageFilePath, size=self.size, color=self.color)

        px = QtGui.QPixmap(p.width() + 10, p.height())
        px.fill(QtCore.Qt.transparent)
        pn = QtGui.QPainter(px)
        pn.drawPixmap(QtCore.QRect(0,0,p.width(),p.height()), p)
        overlayXOffset = p.width() + 2
        overlayYOffset = 0
        if (self.collected):
            pn.drawImage(QtCore.QRect(overlayXOffset, overlayYOffset, 8, 8), self.collectedOverlayIcon)
            overlayYOffset += 8+2
        pn.end()
        return px 
Example #30
Source File: graphics.py    From PyPipboyApp with GNU General Public License v3.0 5 votes vote down vote up
def colorizeImage(image, color, painter = None):
        if not painter:
            endPainter = True
            painter = painter = QtGui.QPainter(image)
        else:
            endPainter = False
        maskImage = QtGui.QImage(image)
        painter.setCompositionMode(QtGui.QPainter.CompositionMode_Multiply)
        painter.fillRect( image.rect(), color)
        painter.setCompositionMode(QtGui.QPainter.CompositionMode_DestinationIn)
        painter.drawImage(0, 0, maskImage)
        if endPainter:
            painter.end()