Esempio n. 1
0
    def __init__(self,
                 text='',
                 color=QtGui.QColor(0, 0, 0),
                 parent=None,
                 scene=None):
        super().__init__(parent=parent, scene=scene)

        self.makePolygon(40)
        self.setPen(QtGui.QPen(color))
        self.setBrush(QtGui.QColor(240, 240, 240))

        self.setFlag(QtWidgets.QGraphicsItem.ItemIgnoresTransformations, True)
        self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
        #self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)

        self.label = QtWidgets.QGraphicsTextItem('', self)
        self.label.setFont(QtGui.QFont('Arial', 8))
        self.label.setPos(-1, 0)
        self.updateText(text)
    def data(self, index, role):
        col = index.column()

        if role == QtCore.Qt.DisplayRole:
            if col == 0:
                return self.path

            else:
                return self.__class__.__name__

        elif role == QtCore.Qt.ForegroundRole:
            return QtGui.QColor('red')

        elif role == QtCore.Qt.BackgroundRole:
            return QtGui.QColor('yellow')

        elif role == QtCore.Qt.DecorationRole:
            if col == 0:
                return icon_provider.icon(self.path)
Esempio n. 3
0
    def create_roi_item(self):
        self.roi = MyROI([20, 20], [500, 500],
                         pen=pg.mkPen(color=(0, 255, 0), size=2))
        self.roi.handlePen = QtGui.QPen(QtGui.QColor(0, 255, 0))
        self.roi.addScaleHandle([1, 1], [0, 0])
        self.roi.addScaleHandle([0, 1], [1, 0])
        self.roi.addScaleHandle([1, 0], [0, 1])
        self.roi.addScaleHandle([0, 0], [1, 1])

        self.roi_shade = RoiShade(self.img_view_box, self.roi)
Esempio n. 4
0
 def _update_palette(self, palette):
     # template and apply the primary stylesheet
     themed_stylesheet = template(self.raw_stylesheet, **palette)
     self.console.style_sheet = themed_stylesheet
     self.console.syntax_style = palette['syntax_style']
     bracket_color = QtGui.QColor(*str_to_rgb(palette['highlight']))
     self.console._bracket_matcher.format.setBackground(bracket_color)
     self.setStyleSheet(themed_stylesheet)
     self.aboutKeybindings.setStyleSheet(themed_stylesheet)
     self.canvas.bgcolor = palette['canvas']
Esempio n. 5
0
    def __init__(self):
        self.bg_color = QtGui.QColor('#000000')
        self.fg_color = QtGui.QColor('#ffffff')
        self.box_color = QtGui.QColor('#00ff00')
        self.line_color = QtGui.QColor('#0080ff')

        self.alert_colors = [
            QtGui.QColor('#775000'),
            QtGui.QColor('#996600'),
            QtGui.QColor('#ffffff'),
            QtGui.QColor('#ffff00'),
            QtGui.QColor('#ff0000'),
            QtGui.QColor('#e700df'),
        ]

        self.use_left = False

        super(plotSTP, self).__init__()
        self.prof = None
Esempio n. 6
0
 def __init__(self, pos):
     self.path = QtGui.QPainterPath(pos)
     super(GalvoLine, self).__init__(self.path)
     self.start = pos
     self.end = pos
     self.path_pen = QtGui.QPen(QtGui.QColor(0, 0, 255))
     self.path_pen.setWidth(2)
     self.setPen(self.path_pen)
     self.setPath(self.path)
     self.mouseIsOver = False
Esempio n. 7
0
File: marker.py Progetto: pixpil/gii
 def __init__(self):
     Panel.__init__(self)
     self._background = QtGui.QColor('#FFC8C8')
     self._markers = []
     self._icons = {}
     self._previous_line = -1
     self.scrollable = True
     self._job_runner = DelayJobRunner(delay=100)
     self.setMouseTracking(True)
     self._to_remove = []
Esempio n. 8
0
    def _color(self, _color):
        """
		desc:
			Safely returns a QColor.

		returns:
			A QColor object.
		"""

        if isinstance(_color, QtGui.QColor):
            return _color
        try:
            hexcolor = color(self.sketchpad.experiment, _color).hexcolor
        except:
            self.notify(
             _(u'Color "%s" is unknown or variably defined, using placeholder color') \
             % _color)
            return QtGui.QColor(self.placeholder_color)
        return QtGui.QColor(hexcolor)
Esempio n. 9
0
    def __init__(self, slider_range, values, parent=None):
        QWidget.__init__(self, parent)
        self.bar_width = 16
        self.slider_width = 8
        self.emit_while_moving = 0
        self.moving = "none"
        self.old_scale_min = 0.0
        self.old_scale_max = 0.0
        self.scale = 0
        self.setMouseTracking(False)
        self.single_step = 0.0

        self.default_collapse_logic = True
        self.collapsable = True
        self.collapsed = False
        self.prev_moving = None
        self.bc_min = None
        self.bc_max = None

        # Variables initialized in methods
        self.scale_min = None
        self.scale_max = None
        self.start_display_min = None
        self.start_display_max = None
        self.start_pos = None
        self.display_min = None
        self.display_max = None

        self.setBarColor(QtGui.QColor(200, 200, 200))
        self.setBackgroundColor(QtGui.QColor(100, 100, 100))
        self.setHandleColor(QtGui.QColor(200, 200, 200))
        self.setHandleBorderColor(QtGui.QColor(200, 200, 200))

        self.setEnabled(True)

        if slider_range:
            self.setRange(slider_range)
        else:
            self.setRange((0.0, 1.0, 0.01))
        if values:
            self.setValues(values)
        else:
            self.setValues((0.3, 0.7))
    def add_entry_to_table(self,
                           row_entries,
                           color=(255, 255, 255),
                           tooltip=''):
        assert len(row_entries) == self.pairing_table.columnCount() - 1
        q_color = QtGui.QColor(*color, alpha=127)
        q_brush = QtGui.QBrush(q_color)

        row_position = self.pairing_table.rowCount()
        self.pairing_table.insertRow(row_position)
        for i, entry in enumerate(row_entries):
            item = QtWidgets.QTableWidgetItem(entry)
            item.setBackground(q_brush)
            item.setToolTip(tooltip)
            if pair_columns[i] == 'pair_name':
                pair_name_widget = table_utils.ValidatedTableItem(
                    self._validate_pair_name_entry)
                pair_name_widget.setText(entry)
                self.pairing_table.setItem(row_position, i, pair_name_widget)
                item.setFlags(QtCore.Qt.ItemIsEnabled)
                item.setFlags(QtCore.Qt.ItemIsSelectable)
            if pair_columns[i] == 'group_1':
                group1_selector_widget = self._group_selection_cell_widget()
                # ensure changing the selection sends an update signal
                group1_selector_widget.currentIndexChanged.connect(
                    lambda: self.on_cell_changed(row_position, 2))
                index = self.get_index_of_text(group1_selector_widget, entry)
                group1_selector_widget.setCurrentIndex(index)
                self.pairing_table.setCellWidget(row_position, i,
                                                 group1_selector_widget)
            if pair_columns[i] == 'group_2':
                group2_selector_widget = self._group_selection_cell_widget()
                # ensure changing the selection sends an update signal
                group2_selector_widget.currentIndexChanged.connect(
                    lambda: self.on_cell_changed(row_position, 3))
                index = self.get_index_of_text(group2_selector_widget, entry)
                group2_selector_widget.setCurrentIndex(index)
                self.pairing_table.setCellWidget(row_position, i,
                                                 group2_selector_widget)
            if pair_columns[i] == 'alpha':
                alpha_widget = table_utils.ValidatedTableItem(
                    self._validate_alpha)
                alpha_widget.setText(entry)
                self.pairing_table.setItem(row_position, i, alpha_widget)
            if pair_columns[i] == 'to_analyse':
                if entry:
                    item.setCheckState(QtCore.Qt.Checked)
                else:
                    item.setCheckState(QtCore.Qt.Unchecked)
            self.pairing_table.setItem(row_position, i, item)
        # guess alpha button
        guess_alpha_widget = self._guess_alpha_button()
        guess_alpha_widget.clicked.connect(
            lambda: self.guess_alpha_clicked_from_row(row_position))
        self.pairing_table.setCellWidget(row_position, 5, guess_alpha_widget)
Esempio n. 11
0
    def _newCurve(self):
        w = self.display.widget

        pen = mkPen(10, len(self.paths) + 2)

        self.curIndex = -1

        p = self.pa.addChild({
            'name': str(len(self.paths) + 1),
            'type': 'empty',
            'highlight': True,
            'removable': True,
            'renamable': True,
            'autoIncrementName': True
        })

        path = FreehandItem(w.imageItem, pen)

        pAdd = p.addChild({
            'name': 'Add',
            'type': 'action',
        })
        pAdd.sigActivated.connect(self._appendToPath)
        pAdd.sigActivated.connect(self._menu.hide)

        pMod = p.addChild({'name': 'Modify', 'type': 'action'})
        pMod.sigActivated.connect(self._modifyPath)
        pMod.sigActivated.connect(self._menu.hide)

        self._initDraw()

        self.paths.append(path)

        color = pen.color()
        pLineColor = p.addChild({
            'name': 'Line color',
            'type': 'color',
            'value': color,
            'path': path
        })
        pLineColor.sigValueChanged.connect(self._changeLineColor)

        br = QtGui.QColor(color)
        br.setAlpha(0)
        path.setBrush(br)

        pFillColor = p.addChild({
            'name': 'Fill color',
            'type': 'color',
            'value': br,
            'path': path
        })
        pFillColor.sigValueChanged.connect(self._changeFillColor)

        self.setChecked(True)
Esempio n. 12
0
    def __init__(self, ws, model_type):
        """
        :param ws:
        :param model_type: MatrixWorkspaceTableViewModelType
        :type model_type: MatrixWorkspaceTableViewModelType
        """
        assert model_type in [
            MatrixWorkspaceTableViewModelType.x,
            MatrixWorkspaceTableViewModelType.y,
            MatrixWorkspaceTableViewModelType.e
        ], "The Model type must be either X, Y or E."

        super(MatrixWorkspaceTableViewModel, self).__init__()

        self.ws = ws
        self.ws_spectrum_info = self.ws.spectrumInfo()
        self.row_count = self.ws.getNumberHistograms()
        self.column_count = self.ws.blocksize()

        self.masked_rows_cache = []
        self.monitor_rows_cache = []
        self.masked_bins_cache = {}

        self.masked_color = QtGui.QColor(240, 240, 240)

        self.monitor_color = QtGui.QColor(255, 253, 209)

        self.type = model_type
        if self.type == MatrixWorkspaceTableViewModelType.x:
            self.relevant_data = self.ws.readX

            # add another column if the workspace is histogram data
            # this will contain the right boundary for the last bin
            if self.ws.isHistogramData():
                self.column_count += 1

        elif self.type == MatrixWorkspaceTableViewModelType.y:
            self.relevant_data = self.ws.readY
        elif self.type == MatrixWorkspaceTableViewModelType.e:
            self.relevant_data = self.ws.readE
        else:
            raise ValueError("Unknown model type {0}".format(self.type))
Esempio n. 13
0
    def paintEvent(self, event):
        _rect = self.rect()
        painter = QtGui.QPainter()
        painter.begin(self)

        # image
        if self._image:
            painter.drawImage(_rect, self._image)

        _font = QtGui.QFont(self._config.get("font-family"))
        _font.setBold(self._config.get("bold"))
        _font.setPixelSize(self._config.get("font-size") * font_scale)
        painter.setFont(_font)

        _margin = self._config.get("margin")
        _text_height = self._config.get("text-height") * font_scale
        for _hud in self._config.get("hud"):
            _horizontally, _vertically, _level = _hud.get("text-align")
            if _vertically == -1:
                _hud_rect = QtCore.QRect(
                    _rect.x() + _margin[0],
                    _rect.y() + _rect.height() -
                    (_margin[3] + _text_height * _level) - _text_height,
                    _rect.width() - _margin[0] - _margin[2], _text_height)
            elif _vertically == 1:
                _hud_rect = QtCore.QRect(
                    _rect.x() + _margin[0],
                    _rect.y() + _margin[1] + _text_height * _level,
                    _rect.width() - _margin[0] - _margin[2], _text_height)
            else:
                pass

            painter.setPen(QtGui.QPen(QtGui.QColor(_hud.get("color"))))

            text = u"未设置"
            exec(_hud.get("cmd"))

            if _horizontally == -1:
                painter.drawText(_hud_rect,
                                 QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter,
                                 text)
            elif _horizontally == 0:
                painter.drawText(
                    _hud_rect, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter,
                    text)
            else:
                painter.drawText(_hud_rect,
                                 QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter,
                                 text)
        # _width =_rect.width()
        # _height =_rect.height()
        # painter.drawRect(_width*0.05,_height*0.05,_width*0.9,_height*0.9)
        #
        painter.end()
Esempio n. 14
0
 def paintEvent(self, event):
     painter = QtGui.QPainter(self)
     painter.setRenderHint(QtGui.QPainter.Antialiasing)
     bounds = QtCore.QRectF(-self.__maxDistance, -self.__maxDistance,
                            self.__maxDistance * 2, self.__maxDistance *
                            2).translated(self._center())
     painter.drawEllipse(bounds)
     painter.setBrush(QtGui.QColor('#AAAAAA'))
     if self.grabCenter:
         painter.drawLine(self._center(), self.movingOffset)
     painter.drawEllipse(self._centerEllipse())
Esempio n. 15
0
    def __init__(self, orientation):
        QtWidgets.QSplitter.__init__(self, orientation)

        pal = self.palette()
        if orientation == Qt.Horizontal:
            pal.setColor(QtGui.QPalette.Background,
                         QtGui.QColor(192, 224, 192))
        elif orientation == Qt.Vertical:
            pal.setColor(QtGui.QPalette.Background,
                         QtGui.QColor(192, 192, 224))
        self.setPalette(pal)

        self.pinarea = PinnedBox(orientation)
        self.scrollarea = ScrollBox(orientation)

        super().addWidget(self.pinarea)
        super().addWidget(self.scrollarea)

        self.collapsed = False
        self.scrollarea.hide()
Esempio n. 16
0
    def setPreferences(self, update_gui=True, **prefs):
        self.bg_color = QtGui.QColor(prefs['bg_color'])
        self.fg_color = QtGui.QColor(prefs['fg_color'])
        self.box_color = QtGui.QColor(prefs['stp_box_color'])
        self.line_color = QtGui.QColor(prefs['stp_line_color'])

        self.alert_colors = [
            QtGui.QColor(prefs['alert_l1_color']),
            QtGui.QColor(prefs['alert_l2_color']),
            QtGui.QColor(prefs['alert_l3_color']),
            QtGui.QColor(prefs['alert_l4_color']),
            QtGui.QColor(prefs['alert_l5_color']),
            QtGui.QColor(prefs['alert_l6_color']),
        ]

        if update_gui:
            self.clearData()
            self.plotBackground()
            self.plotData()
            self.update()
Esempio n. 17
0
 def draw_frame(self, qp):
     '''
     Draws the frame boarders.
     '''
     ## initialize a pen with white color, thickness 2, solid line
     pen = QtGui.QPen(QtGui.QColor(self.fg_color), 2, QtCore.Qt.SolidLine)
     qp.setPen(pen)
     qp.drawLine(self.tlx, self.tly, self.brx, self.tly)
     qp.drawLine(self.brx, self.tly, self.brx, self.bry)
     qp.drawLine(self.brx, self.bry, self.tlx, self.bry)
     qp.drawLine(self.tlx, self.bry, self.tlx, self.tly)
Esempio n. 18
0
    def __init__(self, parent, color=None, **option):
        super(ColorBlock, self).__init__(parent)
        self.setColor(color or QtGui.QColor(1, 1, 1, 1))
        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                           QtWidgets.QSizePolicy.Fixed)

        self.title = option.get('title', 'Color')
        self.pen = QtGui.QPen()
        self.brush = QtGui.QBrush()
        self.brush.setStyle(Qt.SolidPattern)
        self.setCursor(Qt.PointingHandCursor)
Esempio n. 19
0
 def set_splash(self, message):
     """Set splash message"""
     if self.splash is None:
         return
     if message:
         logger.debug(message)
     self.splash.show()
     self.splash.showMessage(
         message, Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
         QtGui.QColor(Qt.white))
     QtWidgets.QApplication.processEvents()
Esempio n. 20
0
File: panel.py Progetto: pixpil/gii
    def on_install(self, editor):
        """
        Extends :meth:`pyqode.core.api.Mode.on_install` method to set the
        editor instance as the parent widget.

        .. warning:: Don't forget to call **super** if you override this
            method!

        :param editor: editor instance
        :type editor: pyqode.core.api.CodeEdit
        """
        Mode.on_install(self, editor)
        self.setParent(editor)
        self.setPalette(QtWidgets.QApplication.instance().palette())
        self.setFont(QtWidgets.QApplication.instance().font())
        self.editor.panels.refresh()
        self._background_brush = QtGui.QBrush(
            QtGui.QColor(self.palette().window().color()))
        self._foreground_pen = QtGui.QPen(
            QtGui.QColor(self.palette().windowText().color()))
Esempio n. 21
0
 def hoverEvent(self, l, ev):
     if ev.enter:
         pen = QtGui.QPen(QtGui.QColor(255, 0, 0))
         pen.setWidth(0)
         l.setPen(pen)
         l.mouseHovering = True
         #self.setCurrentPen(pen)
     elif ev.exit:
         l.setPen(self.pen)
         self.setCurrentPen(self.pen)
         l.mouseHovering = False
Esempio n. 22
0
    def setLoggerBackgroundColor(self):
        """Slot for setting the logger background color."""

        stylesheet = self.sampleTE.styleSheet()
        background = stylesheet[-7:]
        color = QtWidgets.QColorDialog.getColor(QtGui.QColor(background))
        # The selected paper color is applied to the sample text window
        if color.isValid():
            self.new_prefs['Logger/Paper'] = color
            new_stylesheet = stylesheet.replace(background, color.name())
            self.sampleTE.setStyleSheet(new_stylesheet)
Esempio n. 23
0
 def get(self):
     """Override AbstractDataSetWidget method"""
     value = self.item.get()
     if value is not None:
         color = QtGui.QColor(value)
         self.picture = QtGui.QPicture()
         painter = QtGui.QPainter()
         painter.begin(self.picture)
         painter.fillRect(QtCore.QRect(0, 0, 60, 20), QtGui.QBrush(color))
         painter.end()
         self.group.setPicture(self.picture)
Esempio n. 24
0
    def test_colorpicker(self, qtbot, monkeypatch, box):
        # Obtain a random hex color
        color = QG.QColor(hex(randint(256**3)).replace('0x', '#'))

        # Monkey patch the QColorDialog.getColor function
        monkeypatch.setattr(QW.QColorDialog, 'getColor',
                            lambda *args, **kwargs: color)

        # Use the colorpicker
        with qtbot.waitSignal(box.modified):
            qtbot.mouseClick(box.color_label, QC.Qt.LeftButton)
Esempio n. 25
0
    def _set_highlight(self, color):
        for irow in range(self.nrows):
            check = self.checks[irow]
            is_checked = check.checkState()

            # 0 - unchecked
            # 1 - partially checked (invalid)
            # 2 - checked
            if is_checked:
                name_text = self.names_text[irow]
                name_text.setBackground(QtGui.QColor(*color))
Esempio n. 26
0
    def headerData(self, index: int, orientation: QtCore.Qt.Orientation, role: int) -> Any:
        if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
            if index == 0:
                return "Layer Name"
            else:
                return "Via pair"
        elif orientation == QtCore.Qt.Vertical and role == QtCore.Qt.BackgroundRole:
            colors = [i * 255 for i in self.layers[index].color]
            return QtGui.QBrush(QtGui.QColor(*colors))

        return None
Esempio n. 27
0
    def _generateCompPixmap(self, iconPath):
        pixmap = QtGui.QPixmap(iconPath)
        pixmap = pixmap.scaledToHeight(self.ICON_WIDTH,
                                       QtCore.Qt.SmoothTransformation)
        compPixmap = QtGui.QPixmap(pixmap.width() + 32, pixmap.height())
        compPixmap.fill(QtGui.QColor(0, 0, 0, 0))

        painter = QtGui.QPainter(compPixmap)
        painter.drawPixmap(QtCore.QPoint(0, 0), pixmap)
        painter.end()
        return compPixmap
Esempio n. 28
0
    def paintEvent(self, event):
        if not self.pixmap:
            return super(Canvas, self).paintEvent(event)

        p = self._painter
        p.begin(self)
        p.setRenderHint(QtGui.QPainter.Antialiasing)
        p.setRenderHint(QtGui.QPainter.HighQualityAntialiasing)
        p.setRenderHint(QtGui.QPainter.SmoothPixmapTransform)

        p.scale(self.scale, self.scale)
        p.translate(self.offsetToCenter())

        p.drawPixmap(0, 0, self.pixmap)
        Shape.scale = self.scale
        for shape in self.shapes:
            if (shape.selected or not self._hideBackround) and \
                    self.isVisible(shape):
                shape.fill = shape.selected or shape == self.hShape

                #Start Add by Minming draw the text on the left top, comment out now
                #if shape.points != None:
                #p.drawText(shape.points[0].x(), shape.points[0].y(), shape.label)
                #End Add

                shape.paint(p)
        if self.current:
            self.current.paint(p)
            self.line.paint(p)
        if self.selectedShapeCopy:
            self.selectedShapeCopy.paint(p)

        if (self.fillDrawing() and self.createMode == 'polygon'
                and self.current is not None
                and len(self.current.points) >= 2):
            drawing_shape = self.current.copy()
            drawing_shape.addPoint(self.line[1])
            drawing_shape.fill = True
            drawing_shape.fill_color.setAlpha(64)
            drawing_shape.paint(p)

        # Start add by Minming Qian 30-08-2018, paint the reference line
        if self.drawing() and not \
            self.prevPoint.isNull() and not \
            self.outOfPixmap(self.prevPoint):

            p.setPen(QtGui.QColor(0, 0, 0))
            p.drawLine(self.prevPoint.x(), 0, self.prevPoint.x(),
                       self.pixmap.height())
            p.drawLine(0, self.prevPoint.y(), self.pixmap.width(),
                       self.prevPoint.y())
        # End add by Minming Qian 30-08-2018

        p.end()
Esempio n. 29
0
    def setWorkspaceColor(self):
        """Slot for setting the workspace background color."""

        stylesheet = self.workspaceLabel.styleSheet()
        background = stylesheet[-7:]
        color = QtWidgets.QColorDialog.getColor(QtGui.QColor(background))
        # The selected color is applied to the sample label besides the button
        if color.isValid():
            self.new_prefs['Workspace/Background'] = QtGui.QBrush(color)
            new_stylesheet = stylesheet.replace(background, color.name())
            self.workspaceLabel.setStyleSheet(new_stylesheet)
Esempio n. 30
0
    def create_cmap_icon(cmap, size):
        """
        Creates a :obj:`~PyQt5.QtGui.QIcon` object of the given `cmap` with the
        provided `size`.

        Parameters
        ----------
        cmap : :obj:`~matplotlib.colors.Colormap` object or str
            The colormap for which an icon needs to be created.
        size : tuple
            A tuple containing the width and height dimension values of the
            icon to be created.

        Returns
        -------
        icon : :obj:`~PyQt5.QtGui.QIcon` object
            The instance of the :class:`~PyQt5.QtGui.QIcon` class that was
            created from the provided `cmap` and `size`.

        """

        # Obtain the cmap
        cmap = cm.get_cmap(cmap)

        # Obtain the RGBA values of the colormap
        # TODO: Figure out why setting 256 to cmap.N does not work for N > 256
        x = np.linspace(0, 1, 256)
        rgba = cmap(x)

        # Convert to Qt RGBA values
        rgba = [
            QG.QColor(int(r * 255), int(g * 255), int(b * 255),
                      int(a * 255)).rgba() for r, g, b, a in rgba
        ]

        # Create an image object
        image = QG.QImage(256, 1, QG.QImage.Format_Indexed8)

        # Set the value of every pixel in this image
        image.setColorTable(rgba)
        for i in range(256):
            image.setPixel(i, 0, i)

        # Scale the image to its proper size
        image = image.scaled(*size)

        # Convert the image to a pixmap
        pixmap = QG.QPixmap.fromImage(image)

        # Convert the pixmap to an icon
        icon = QG.QIcon(pixmap)

        # Return the icon
        return (icon)