Python PyQt5.QtGui.QPixmap() Examples

The following are 30 code examples of PyQt5.QtGui.QPixmap(). 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: angrysearch.py    From ANGRYsearch with GNU General Public License v2.0 11 votes vote down vote up
def get_tray_icon(self):
        base64_data = '''iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABHN
                         CSVQICAgIfAhkiAAAAQNJREFUOI3t1M9KAlEcxfHPmP0xU6Ogo
                         G0teoCiHjAIfIOIepvKRUE9R0G0KNApfy0c8hqKKUMrD9zVGc4
                         9nPtlsgp5n6qSVSk7cBG8CJ6sEX63UEcXz4jE20YNPbygPy25Q
                         o6oE+fEPXFF7A5yA9Eg2sQDcU3sJd6k89O4iiMcYKVol3rH2Mc
                         a1meZ4hMdNPCIj+SjHHfFZU94/0Nwlv4rWoY7vhrdeLNoO86bG
                         lym/ge3lsHDdI2fojbBG6sUtzOiQ1wQOwk6GwWKHeJyHtxOcFi
                         0TpFaxmnhNcyIW45bQ6RS3Hq4MeB7Ltyahki9Gd2xidWiwG9va
                         nCZqi7xlZGVHfwN6+5nU/ccBUYAAAAASUVORK5CYII='''

        pm = Qg.QPixmap()
        pm.loadFromData(base64.b64decode(base64_data))
        i = Qg.QIcon()
        i.addPixmap(pm)
        return i

    # OFF BY DEFAULT
    # 0.2 SEC DELAY TO LET USER FINISH TYPING BEFORE INPUT BECOMES A DB QUERY 
Example #2
Source File: CuraSplashScreen.py    From Cura with GNU Lesser General Public License v3.0 6 votes vote down vote up
def __init__(self):
        super().__init__()
        self._scale = 0.7
        self._version_y_offset = 0  # when extra visual elements are in the background image, move version text down

        if ApplicationMetadata.IsEnterpriseVersion:
            splash_image = QPixmap(Resources.getPath(Resources.Images, "cura_enterprise.png"))
            self._version_y_offset = 26
        else:
            splash_image = QPixmap(Resources.getPath(Resources.Images, "cura.png"))

        self.setPixmap(splash_image)

        self._current_message = ""

        self._loading_image_rotation_angle = 0

        self._to_stop = False
        self._change_timer = QTimer()
        self._change_timer.setInterval(50)
        self._change_timer.setSingleShot(False)
        self._change_timer.timeout.connect(self.updateLoadingImage)

        self._last_update_time = None 
Example #3
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 #4
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 #5
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 #6
Source File: WaveformDialog.py    From pyweed with GNU Lesser General Public License v3.0 6 votes vote down vote up
def setWaveform(self, waveform):
        if waveform and waveform.error:
            self.setForeground(self.errorForeground)
        else:
            self.setForeground(self.defaultForeground)
        if waveform:
            if waveform.loading or waveform.error or not waveform.image_exists:
                self.imagePath = None
                self.setData(QtCore.Qt.DecorationRole, None)
                if waveform.loading:
                    self.setText('Loading waveform data...')
                elif waveform.error:
                    self.setText(waveform.error)
                else:
                    self.setText('')
            else:
                if waveform.image_path != self.imagePath:
                    self.imagePath = waveform.image_path
                    pic = QtGui.QPixmap(waveform.image_path)
                    self.setData(QtCore.Qt.DecorationRole, pic)
                    self.setText('')
        else:
            self.imagePath = None
            self.setText('') 
Example #7
Source File: table.py    From dunya-desktop with GNU General Public License v3.0 6 votes vote down vote up
def set_status(self, raw, exist=None):
        item = QLabel()
        item.setAlignment(Qt.AlignCenter)

        if exist is 0:
            icon = QPixmap(QUEUE_ICON).scaled(20, 20, Qt.KeepAspectRatio,
                                              Qt.SmoothTransformation)
            item.setPixmap(icon)
            item.setToolTip('Waiting in the download queue...')

        if exist is 1:
            icon = QPixmap(CHECK_ICON).scaled(20, 20, Qt.KeepAspectRatio,
                                              Qt.SmoothTransformation)
            item.setPixmap(icon)
            item.setToolTip('All the features are downloaded...')

        if exist is 2:
            item = QPushButton(self)
            item.setToolTip('Download')
            item.setIcon(QIcon(DOWNLOAD_ICON))
            item.clicked.connect(self.download_clicked)

        self.setCellWidget(raw, 0, item) 
Example #8
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 #9
Source File: lab6.py    From Computer-graphics with MIT License 6 votes vote down vote up
def get_pixel(point):
    global w, point_zat, circle
    pix = QPixmap()
    if circle:
        r = w.rad.value()
        draw_circle(w.image, r, point)
        circle = False
    if point_zat:
        w.p_x.setValue(point.x())
        w.p_y.setValue(point.y())
        draw_edges(w.image, w.edges)
        point_zat = False
    pix.convertFromImage(w.image)
    w.scene.addPixmap(pix)
    w.lock.setDisabled(False)
    w.erase.setDisabled(False)
    w.paint.setDisabled(False)
    w.addpoint.setDisabled(False)
    w.addcircle.setDisabled(False)
    w.pixel.setDisabled(False) 
Example #10
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 #11
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 #12
Source File: about_dlg.py    From dash-masternode-tool with MIT License 6 votes vote down vote up
def setupUi(self):
        ui_about_dlg.Ui_AboutDlg.setupUi(self, self)
        self.setWindowTitle("About")
        img = QPixmap(os.path.join(self.app_config.app_dir, "img/dmt.png"))
        img = img.scaled(QSize(64, 64))
        self.lblImage.setPixmap(img)
        self.lblAppName.setText('Dash Masternode Tool ' + self.app_version_str)
        self.textAbout.setOpenExternalLinks(True)
        self.textAbout.viewport().setAutoFillBackground(False)
        if sys.platform == 'win32':
            self.resize(600, 310)
            self.textAbout.setHtml(self.textAbout.toHtml().replace('font-size:11pt', 'font-size:10pt'))
            self.textAbout.setHtml(self.textAbout.toHtml().replace('font-size:9pt', 'font-size:8pt'))
        elif sys.platform == 'darwin':
            self.textAbout.setHtml(self.textAbout.toHtml().replace('font-size:11pt', 'font-size:13pt'))
        elif sys.platform == 'linux':
            self.resize(620, 320)
        # self.layout().setSizeConstraint(QLayout.SetFixedSize) 
Example #13
Source File: main.py    From csb with GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        self.ui = uic.loadUi(getLoc('GUIS/PDConfig.ui'), self)
        self.setWindowIcon(QtGui.QIcon(getLoc('GUIS/icon.png')))
        self.logo.setPixmap(QtGui.QPixmap(getLoc('GUIS/title.png')))
        self.cc = True
        p = self.palette()
        p.setColor(self.backgroundRole(), QtCore.Qt.white)
        self.setPalette(p)
        self.updateRegion()
        self.populateCC()
        self.ui.continue_btn.clicked.connect(self.cont)
        self.ui.save_btn.clicked.connect(self.saveConfig)
        self.loadToolTips() 
Example #14
Source File: desktopLyricButtons.py    From MusicBox with MIT License 5 votes vote down vote up
def loadPixmap(self, pic_name):
        self.pixmap = QtGui.QPixmap(pic_name)
        self.btn_width = self.pixmap.width()
        self.btn_height = self.pixmap.height()
        self.setFixedSize(self.btn_width, self.btn_height) 
Example #15
Source File: desktopLyricButtons.py    From MusicBox with MIT License 5 votes vote down vote up
def loadPixmap(self, pic_name):
        self.pixmap = QtGui.QPixmap(pic_name)
        self.btn_width = self.pixmap.width()/4
        self.btn_height = self.pixmap.height()
        self.setFixedSize(self.btn_width, self.btn_height) 
Example #16
Source File: desktopLyricButtons.py    From MusicBox with MIT License 5 votes vote down vote up
def loadPixmap(self, pic_name):
        self.pixmap = QtGui.QPixmap(pic_name)
        self.btn_width = self.pixmap.width()
        self.btn_height = self.pixmap.height()/6
        self.setFixedSize(self.btn_width, self.btn_height) 
Example #17
Source File: Banners.py    From qiew with GNU General Public License v2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example #18
Source File: HexViewMode.py    From qiew with GNU General Public License v2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example #19
Source File: DisasmViewMode.py    From qiew with GNU General Public License v2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example #20
Source File: DisasmViewMode.py    From dcc with Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example #21
Source File: lab10.py    From Computer-graphics with MIT License 5 votes vote down vote up
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) 
Example #22
Source File: SourceViewMode.py    From dcc with Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example #23
Source File: lab3.py    From Computer-graphics with MIT License 5 votes vote down vote up
def draw_sun(win):
    d = win.spin_dia.value()
    spin = win.spin_angle.value()
    bx = 255
    by = 255
    win.image.fill(win.color_bground)
    is_standart = False
    for i in np.arange(0, 360, spin):
        ex = cos(radians(i)) * d + 255
        ey = sin(radians(i)) * d + 255

        if win.cda.isChecked():
            start = time.clock()
            line_DDA(win, [bx, by], [ex, ey])
            end = time.clock()
        if win.br_float.isChecked():
            start = time.clock()
            line_br_float(win, [bx, by], [ex, ey])
            end = time.clock()
        if win.br_int.isChecked():
            start = time.clock()
            line_br_int(win, [bx, by], [ex, ey])
            end = time.clock()
        if win.br_smooth.isChecked():
            start = time.clock()
            line_br_smooth(win, [bx, by], [ex, ey])
            end = time.clock()
        if win.lib.isChecked():
            is_standart = True
            start = time.clock()
            win.scene.addLine(bx, by, ex, ey, win.pen)
            end = time.clock()

    if not is_standart:
        pix = QPixmap(511, 511)
        pix.convertFromImage(win.image)
        win.scene.addPixmap(pix)

    win.label.setText("{0:.3f}msc".format((end - start) * 1000)) 
Example #24
Source File: lab3.py    From Computer-graphics with MIT License 5 votes vote down vote up
def draw_line(win):
    bx = win.begin_x.value()
    by = win.begin_y.value()
    ex = win.end_x.value()
    ey = win.end_y.value()
    is_standart =False
    win.image.fill(win.color_bground)
    if win.cda.isChecked():
        start = time.clock()
        line_DDA(win, [bx, by], [ex, ey])
        end = time.clock()
    if win.br_float.isChecked():
        start = time.clock()
        line_br_float(win, [bx, by], [ex, ey])
        end = time.clock()
    if win.br_int.isChecked():
        start = time.clock()
        line_br_int(win, [bx, by], [ex, ey])
        end = time.clock()
    if win.br_smooth.isChecked():
        start = time.clock()
        line_br_smooth(win, [bx, by], [ex, ey])
        end = time.clock()
    if win.lib.isChecked():
        is_standart = True
        start = time.clock()
        win.scene.addLine(bx, by, ex, ey, win.pen)
        end = time.clock()

    if not is_standart:
        pix = QPixmap(511, 511)
        pix.convertFromImage(win.image)
        win.scene.addPixmap(pix)

    win.label.setText("{0:.3f}msc".format((end - start)*1000)) 
Example #25
Source File: detection.py    From detection with GNU General Public License v2.0 5 votes vote down vote up
def drawRects(self, source, rectsTree, scale):
        """Draw rectangles in 'rectsTree' on 'source'.
        """
        pixmap = QPixmap(source)
        self.drawBackground(pixmap)

        def drawRect(node, parentHash):
            painter = QtGui.QPainter(pixmap)
            roi, param, tracking = node.data
            x, y, w, h = common.scaleRect(roi, scale)
            painter.setPen(param.color)
            funcTable = {
                self.FILL_MASK: self.fillMask,
                self.FILL_BLUR: self.fillBlur,
                self.FILL_IMAGE: self.fillImage,
                self.FILL_COLOR: self.fillColor,
                self.FILL_OUTLINE: self.fillOutline
                         }
            for fill, func in funcTable.iteritems():
                if param.fill == fill:
                    func(pixmap, painter, (x, y, w, h), param, source)
            if param.tracking:
                self.drawTracking(painter, tracking, scale)
            if param.showName:
                painter.drawText(x, y, param.name)
            return param.hash

        h, w = pixmap.height(), pixmap.width()
        rectsTree.map(None, drawRect)
        painter = QtGui.QPainter(source)
        painter.drawPixmap(0, 0, pixmap) 
Example #26
Source File: Banners.py    From dcc with Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example #27
Source File: detection.py    From detection with GNU General Public License v2.0 5 votes vote down vote up
def getMask(self, pixmap, x, y, w, h, shape, overlay,
                bg=QtCore.Qt.transparent, fg=QtCore.Qt.black, progressive=False):
        """Create a shape mask with the same size of pixmap.
        """
        mask = QPixmap(pixmap.width(), pixmap.height())
        mask.fill(bg)
        path = QtGui.QPainterPath()

        if progressive:
            progressive = QPixmap(pixmap.width(), pixmap.height())
            progressive.fill(QtCore.Qt.transparent)
            progressiveMask = QPixmap(self.MASK_PATH)
            progressiveMask = progressiveMask.scaled(w, h, QtCore.Qt.IgnoreAspectRatio)
            progressivePainter = QtGui.QPainter(progressive)
            progressivePainter.drawPixmap(x, y, progressiveMask)
            del progressivePainter
            fg = QtGui.QBrush(progressive)

        painter = QtGui.QPainter(mask)
        if shape == self.SHAPE_ELLIPSE:
            path.addEllipse(x, y, w, h)
            painter.fillPath(path, fg)
        elif shape == self.SHAPE_RECT:
            painter.fillRect(x, y, w, h, fg)

        painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceAtop)
        if overlay:
            painter.drawPixmap(0, 0, overlay)
        return mask 
Example #28
Source File: detection.py    From detection with GNU General Public License v2.0 5 votes vote down vote up
def getIcon(self, color):
        """Returns a colored icon.
        """
        pixmap = QPixmap(14, 14)
        pixmap.fill(color)
        return QIcon(pixmap) 
Example #29
Source File: HexViewMode.py    From dcc with Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example #30
Source File: Banners.py    From qiew with GNU General Public License v2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height)