Пример #1
0
def update_gview_with_image_file(image_full_path, gview):
    """updates the QGraphicsView with the given image
    """

    if not isinstance(gview, QtWidgets.QGraphicsView):
        return

    clear_thumbnail(gview)

    if image_full_path != "":
        image_full_path = os.path.normpath(image_full_path)
        image_format = os.path.splitext(image_full_path)[-1].replace(
            '.', '').upper()
        logger.debug("creating pixmap from: %s" % image_full_path)

        # size = conf.thumbnail_size
        # width = size[0]
        # height = size[1]
        size = gview.size()
        width = size.width()
        height = size.height()
        logger.debug('width: %s' % width)
        logger.debug('height: %s' % height)

        if os.path.exists(image_full_path):
            pixmap = QtGui.QPixmap(image_full_path,
                                   format=image_format).scaled(
                                       width, height,
                                       QtCore.Qt.KeepAspectRatio,
                                       QtCore.Qt.SmoothTransformation)
            # pixmap = QtGui.QPixmap(image_full_path, format='JPG')

            scene = gview.scene()
            scene.addPixmap(pixmap)
Пример #2
0
    def __init__(self, *args, **kwargs):
        self.entity_type = kwargs.pop('entity_type', None)

        pixmap = QtGui.QPixmap(20, 20)
        super(TaskIcon, self).__init__(pixmap)

        loaded_font_families = load_font('FontAwesome.otf')
        # default_font = QtGui.QFont()
        self.icon_font = QtGui.QFont()

        if loaded_font_families:
            self.icon_font.setFamily(loaded_font_families[0])
            self.icon_font.setPixelSize(14)