コード例 #1
0
ファイル: utils.py プロジェクト: yangbiaocn/inkcut
def color_icon(color):
    pixmap = QPixmap(12, 12)
    if color is None:
        color = Color(0, 0, 0, 0)
    pixmap.fill(get_cached_qcolor(color))
    icg = IconImage(image=Image(_tkdata=pixmap.toImage()))
    return Icon(images=[icg])
コード例 #2
0
 def snapshot(self):
     """ Take a snapshot of the window and close it.
     
     """
     widget = self.view.proxy.widget
     framesize =  widget.window().frameSize()
     QPixmap.grabWindow(QApplication.desktop().winId(), widget.x(),
                        widget.y(), framesize.width(),
                        framesize.height() ).save(self.path)
     widget.close()
コード例 #3
0
 def snapshot(self):
     """ Take a snapshot of the window and close it.
     
     """
     widget = self.view.proxy.widget
     framesize = widget.window().frameSize()
     QPixmap.grabWindow(QApplication.desktop().winId(), widget.x(),
                        widget.y(), framesize.width(),
                        framesize.height()).save(self.path)
     widget.close()
コード例 #4
0
ファイル: qt_graphics_view.py プロジェクト: frmdstryr/enamlx
    def do_drag(self, widget):
        """Perform the drag operation for the widget.

        Parameters
        ----------
        widget: QWidget
            A reference to the viewport widget.

        """
        drag_data = self.declaration.drag_start()
        if drag_data is None:
            return
        # widget = self.widget
        qdrag = QDrag(widget)
        qdrag.setMimeData(drag_data.mime_data.q_data())
        if drag_data.image is not None:
            qimg = get_cached_qimage(drag_data.image)
            qdrag.setPixmap(QPixmap.fromImage(qimg))
        # else:
        # if __version_info__ < (5, ):
        # qdrag.setPixmap(QPixmap.grabWidget(self.widget))
        # else:
        # qdrag.setPixmap(widget.grab())
        if drag_data.hotspot:
            qdrag.setHotSpot(QPoint(*drag_data.hotspot))
        else:
            cursor_position = widget.mapFromGlobal(QCursor.pos())
            qdrag.setHotSpot(cursor_position)
        default = Qt.DropAction(drag_data.default_drop_action)
        supported = Qt.DropActions(drag_data.supported_actions)
        qresult = qdrag.exec_(supported, default)
        self.declaration.drag_end(drag_data, DropAction(int(qresult)))
コード例 #5
0
ファイル: image_view_ex.py プロジェクト: Trevol/PyQT_Test
def _get_pixmap(image):
    if image is None:
        return None
    # w, h, format = _get_image_size_n_format(image)
    # qimage = QImage(image.data, w, h, image.strides[0], format)
    qimage = ndarray_to_qimage(image)
    return QPixmap.fromImage(qimage)
コード例 #6
0
ファイル: q_dock_tab_widget.py プロジェクト: zxyfanta/enaml
    def _snapAlertPixmaps(self, index, level):
        """ Snap the alert pixmaps for the specified tab.

        Parameters
        ----------
        index : int
            The index of the tab of interest.

        level : unicode
            The alert level for which to snap the pixmaps.

        """
        # Force an internal update of the stylesheet rules
        self.setProperty(u'alert', level)
        repolish(self)

        # Setup the style option for the control
        opt = QStyleOptionTab()
        self.initStyleOption(opt, index)
        opt.rect.moveTo(0, 0)

        # Snap the normal pixmap
        opt.state &= ~QStyle.State_Selected
        normal = QPixmap(opt.rect.size())
        normal.fill(Qt.transparent)
        painter = QStylePainter(normal, self)
        painter.initFrom(self)
        painter.drawControl(QStyle.CE_TabBarTab, opt)

        # Snap the selected pixmap
        opt.state |= QStyle.State_Selected
        selected = QPixmap(opt.rect.size())
        selected.fill(Qt.transparent)
        painter = QStylePainter(selected, self)
        painter.initFrom(self)
        painter.drawControl(QStyle.CE_TabBarTab, opt)

        # Reset the internal stylesheet style
        self.setProperty(u'alert', None)
        repolish(self)

        # Update the internal tab data
        data = self._tab_data[index]
        data.normal = normal
        data.selected = selected
        data.alerted = True

        # Flip the alert flag so the pixmaps are painted
        self._has_alerts = True
コード例 #7
0
    def _snapAlertPixmaps(self, index, level):
        """ Snap the alert pixmaps for the specified tab.

        Parameters
        ----------
        index : int
            The index of the tab of interest.

        level : unicode
            The alert level for which to snap the pixmaps.

        """
        # Force an internal update of the stylesheet rules
        self.setProperty(u'alert', level)
        repolish(self)

        # Setup the style option for the control
        opt = QStyleOptionTabV3()
        self.initStyleOption(opt, index)
        opt.rect.moveTo(0, 0)

        # Snap the normal pixmap
        opt.state &= ~QStyle.State_Selected
        normal = QPixmap(opt.rect.size())
        normal.fill(Qt.transparent)
        painter = QStylePainter(normal, self)
        painter.initFrom(self)
        painter.drawControl(QStyle.CE_TabBarTab, opt)

        # Snap the selected pixmap
        opt.state |= QStyle.State_Selected
        selected = QPixmap(opt.rect.size())
        selected.fill(Qt.transparent)
        painter = QStylePainter(selected, self)
        painter.initFrom(self)
        painter.drawControl(QStyle.CE_TabBarTab, opt)

        # Reset the internal stylesheet style
        self.setProperty(u'alert', None)
        repolish(self)

        # Update the internal tab data
        data = self._tab_data[index]
        data.normal = normal
        data.selected = selected
        data.alerted = True

        # Flip the alert flag so the pixmaps are painted
        self._has_alerts = True
コード例 #8
0
ファイル: qt_graphics_view.py プロジェクト: frmdstryr/enamlx
 def set_image(self, image):
     self.widget.setPixmap(QPixmap.fromImage(get_cached_qimage(image)))