Python PyQt5.QtGui.QPixmap() Examples

The following are 30 code examples for showing how to use PyQt5.QtGui.QPixmap(). These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: ANGRYsearch   Author: DoTheEvo   File: angrysearch.py    License: GNU General Public License v2.0 7 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
Project: dcc   Author: amimo   File: DisasmViewMode.py    License: 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 3
Project: dcc   Author: amimo   File: SourceViewMode.py    License: 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 4
Project: dcc   Author: amimo   File: BinViewMode.py    License: 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 5
Project: pyweed   Author: iris-edu   File: WaveformDialog.py    License: 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 6
Project: dunya-desktop   Author: MTG   File: table.py    License: 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 7
Project: detection   Author: xsyann   File: detection.py    License: 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 8
Project: Computer-graphics   Author: Panda-Lewandowski   File: lab6.py    License: 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 9
Project: qiew   Author: mtivadar   File: DisasmViewMode.py    License: 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 10
Project: qiew   Author: mtivadar   File: BinViewMode.py    License: 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 11
Project: dash-masternode-tool   Author: Bertrand256   File: about_dlg.py    License: 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 12
Project: Cura   Author: Ultimaker   File: CuraSplashScreen.py    License: 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 13
Project: pkmeter   Author: pkkid   File: pkmixins.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _build_pixmap(self, input):
        if isinstance(self.bgimage, bytes):
            pixmap = QtGui.QPixmap()
            pixmap.loadFromData(self.bgimage)
        else:
            pixmap = QtGui.QPixmap(self.bgimage)
        return pixmap 
Example 14
Project: idasec   Author: RobinDavid   File: MainWidget.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnCreate(self, _):
        self.setupUi(self)
        self.binsec_connect_button.clicked.connect(self.connect_binsec)
        self.dba_decode_button.clicked.connect(self.decode_button_clicked)
        self.here_decode_button.clicked.connect(self.decode_here_clicked)
        self.pinsec_ip_field.setText("192.168.56.101")
        self.pinsec_port_field.setText("5555")
        self.binsec_port_field.setValidator(QtGui.QIntValidator(0, 65535))
        self.pinsec_port_field.setValidator(QtGui.QIntValidator(0, 65535))
        self.ok = QtGui.QPixmap(":/icons/icons/oxygen/22x22/ok.png")
        self.ko = QtGui.QPixmap(":/icons/icons/oxygen/22x22/ko.png")
        self.prev_modules = sys.modules.keys()
        self.set_pinsec_visible(False) 
Example 15
Project: dcc   Author: amimo   File: DisasmViewMode.py    License: Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example 16
Project: dcc   Author: amimo   File: SourceViewMode.py    License: Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example 17
Project: dcc   Author: amimo   File: HexViewMode.py    License: Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example 18
Project: dcc   Author: amimo   File: Banners.py    License: Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example 19
Project: dcc   Author: amimo   File: Banners.py    License: Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example 20
Project: dcc   Author: amimo   File: Banners.py    License: Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example 21
Project: dcc   Author: amimo   File: BinViewMode.py    License: Apache License 2.0 5 votes vote down vote up
def _getNewPixmap(self, width, height):
        return QtGui.QPixmap(width, height) 
Example 22
Project: easygui_qt   Author: aroberge   File: utils.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_image_to_layout(layout, image_file_name):
    '''adds an image, as a QLabel, to a layout'''
    label =  qt_widgets.QLabel()
    pixmap =  QtGui.QPixmap(image_file_name)
    label.setPixmap(pixmap)
    layout.addWidget(label) 
Example 23
Project: easygui_qt   Author: aroberge   File: wizard_maker.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def create_page(self, page):
        new_page = qt_widgets.QWizardPage()
        layout = qt_widgets.QVBoxLayout()
        for kind, value in page:
            if kind.lower() == "title":
                new_page.setTitle(value)
            elif kind.lower() == "text":
                label = qt_widgets.QLabel(value)
                label.setWordWrap(True)
                layout.addWidget(label)
            elif kind.lower() == "image":
                label =  qt_widgets.QLabel()
                pixmap =  QtGui.QPixmap(value)
                label.setPixmap(pixmap)
                layout.addWidget(label)
            elif kind.lower() == "many images":
                h_layout = qt_widgets.QHBoxLayout()
                h_box = qt_widgets.QGroupBox('')
                for image in value:
                    label =  qt_widgets.QLabel()
                    pixmap =  QtGui.QPixmap(image)
                    label.setPixmap(pixmap)
                    h_layout.addWidget(label)
                h_box.setLayout(h_layout)
                layout.addWidget(h_box)
        new_page.setLayout(layout)
        self.addPage(new_page) 
Example 24
Project: raspiblitz   Author: rootzoll   File: main.py    License: MIT License 5 votes vote down vote up
def check_invoice(self, flag, tick=0):
        log.info("checking invoice paid (Tick: {})".format(tick))
        self.invoice_to_check_flag = flag

        if tick >= INVOICE_CHECK_TIMEOUT:
            log.debug("canceled checking invoice paid")
            flag.set()

        if IS_DEV_ENV:
            res = False
            amt_paid_sat = 123123402

            if tick == 5:
                res = True

        else:
            with ReadOnlyStub(network=self.rb_cfg.network, chain=self.rb_cfg.chain) as stub_readonly:
                res, amt_paid_sat = check_invoice_paid(stub_readonly, self.invoice_to_check)
                log.debug("result of invoice check: {}".format(res))

        if res:
            log.debug("paid!")
            self.ui_qr_code.qcode.setMargin(8)
            self.ui_qr_code.qcode.setPixmap(QPixmap(":/RaspiBlitz/images/Paid_Stamp.png"))

            if amt_paid_sat:
                self.ui_qr_code.status_value.setText("Paid")
                self.ui_qr_code.amt_paid_value.setText("{}".format(amt_paid_sat))
            else:
                self.ui_qr_code.status_value.setText("Paid")

            flag.set() 
Example 25
Project: raspiblitz   Author: rootzoll   File: main.py    License: MIT License 5 votes vote down vote up
def generate_qr_code_finished(self, img):
        buf = BytesIO()
        img.save(buf, "PNG")

        qt_pixmap = QPixmap()
        qt_pixmap.loadFromData(buf.getvalue(), "PNG")
        self.ui_qr_code.spinner.stop()
        self.ui_qr_code.qcode.setMargin(2)
        self.ui_qr_code.qcode.setPixmap(qt_pixmap) 
Example 26
Project: qutebrowser   Author: qutebrowser   File: test_tabwidget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_small_icon_doesnt_crash(self, widget, qtbot, fake_web_tab):
        """Test that setting a small icon doesn't produce a crash.

        Regression test for #1015.
        """
        # Size taken from issue report
        pixmap = QPixmap(72, 1)
        icon = QIcon(pixmap)
        tab = fake_web_tab()
        widget.addTab(tab, icon, 'foobar')

        with qtbot.waitExposed(widget):
            widget.show()

    # Sizing tests 
Example 27
Project: qutebrowser   Author: qutebrowser   File: app.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _init_icon():
    """Initialize the icon of qutebrowser."""
    fallback_icon = QIcon()
    for size in [16, 24, 32, 48, 64, 96, 128, 256, 512]:
        filename = ':/icons/qutebrowser-{size}x{size}.png'.format(size=size)
        pixmap = QPixmap(filename)
        if pixmap.isNull():
            log.init.warning("Failed to load {}".format(filename))
        else:
            fallback_icon.addPixmap(pixmap)
    icon = QIcon.fromTheme('qutebrowser', fallback_icon)
    if icon.isNull():
        log.init.warning("Failed to load icon")
    else:
        q_app.setWindowIcon(icon) 
Example 28
Project: PornHub_downloader   Author: QuantumLiu   File: Ui_gui.py    License: MIT License 5 votes vote down vote up
def show_cover(self,cover_url):
        print(cover_url)
        data=requests.get(cover_url,headers=self.headers,proxies=self.proxies).content
        qp = QtGui.QPixmap()
        qp.loadFromData(data)
        self.lb_cover.setPixmap(qp) 
Example 29
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: intro_dlg.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _init_ui(self):
        title_qll = QtWidgets.QLabel("The system tray")
        title_qll.setFont(mc.mc_global.get_font_xxlarge(i_bold=True))
        title_qll.setAlignment(QtCore.Qt.AlignHCenter)

        description_qll = QtWidgets.QLabel(
            "When you run Mindfulness at the computer it is accessible via the system tray. "
            "From the menu that opens when clicking on this icon "
            "you can adjust settings or invoke a breathing or rest session"
        )
        description_qll.setWordWrap(True)
        description_qll.setFont(mc.mc_global.get_font_xlarge())

        system_tray_qll = QtWidgets.QLabel()
        system_tray_qll.setPixmap(QtGui.QPixmap(mc.mc_global.get_app_icon_path("icon-br.png")))
        system_tray_qll.setAlignment(QtCore.Qt.AlignHCenter)

        vbox_l3 = QtWidgets.QVBoxLayout()
        vbox_l3.addSpacing(MARGIN_TOP_INT)
        vbox_l3.addWidget(title_qll)
        vbox_l3.addStretch(1)
        vbox_l3.addWidget(description_qll)
        vbox_l3.addStretch(1)
        vbox_l3.addWidget(system_tray_qll)
        vbox_l3.addStretch(1)

        hbox_l2 = QtWidgets.QHBoxLayout()
        hbox_l2.addStretch(1)
        hbox_l2.addLayout(vbox_l3)
        hbox_l2.addStretch(1)

        self.setLayout(hbox_l2) 
Example 30
Project: Traffic-Rules-Violation-Detection   Author: rahatzamancse   File: Database.py    License: GNU General Public License v3.0 5 votes vote down vote up
def search(self, cam=None, color=None, license=None, time=None):
        cur = self.con.cursor()
        command = "SELECT camera.location, cars.id, cars.color, cars.first_sighted, cars.license_image, " \
                  " cars.license_number, cars.car_image, cars.num_rules_broken, cars.owner," \
                  " rules.name, rules.fine, violations.time, rules.id" \
                  " FROM violations, rules, cars, camera" \
                  " where rules.id = violations.rule" \
                  " and violations.camera = camera.id" \
                  " and cars.id = violations.car"

        if cam is not None:
            command = command + " and violations.camera = '" + str(cam) + "'"
        if color is not None:
            command = command + " and cars.color = '" + str(color) + "'"
        if time is not None:
            command = command + " and violations.time >= " + str(
                self.covert_time_to_bd(time[0])) + " and violations.time <= " + str(self.covert_time_to_bd(time[1]))

        cur.execute(command)
        rows = cur.fetchall()
        ret = []
        for row in rows:
            ret.append({
                KEYS.LOCATION: row[0],
                KEYS.CARID: row[1],
                KEYS.CARCOLOR: row[2],
                KEYS.FIRSTSIGHTED: row[3],
                KEYS.CARIMAGE: QPixmap("car_images/" + row[4]),
                KEYS.LICENSENUMBER: row[5],
                KEYS.LICENSEIMAGE: QPixmap("license_images/" + row[6]),
                KEYS.NUMRULESBROKEN: row[7],
                KEYS.CAROWNER: row[8],
                KEYS.RULENAME: row[9],
                KEYS.RULEFINE: row[10],
                KEYS.TIME: row[11],
                KEYS.RULEID: row[12],
            })
        cur.close()
        return ret