当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QPixmap方法代码示例

本文整理汇总了Python中qtpy.QtGui.QPixmap方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QPixmap方法的具体用法?Python QtGui.QPixmap怎么用?Python QtGui.QPixmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtpy.QtGui的用法示例。


在下文中一共展示了QtGui.QPixmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __add_result

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __add_result(self, result: Mapping[str, Any]) -> None:
        """Add result items, except add to the list."""
        item = QListWidgetItem(result['algorithm'])
        interrupt = result['interrupted']
        if interrupt == 'False':
            interrupt_icon = "task_completed.png"
        elif interrupt == 'N/A':
            interrupt_icon = "question.png"
        else:
            interrupt_icon = "interrupted.png"
        item.setIcon(QIcon(QPixmap(f":/icons/{interrupt_icon}")))
        if interrupt == 'False':
            interrupt_text = "No interrupt."
        else:
            interrupt_text = f"Interrupt at: {interrupt}"
        text = f"{result['algorithm']} ({interrupt_text})"
        if interrupt == 'N/A':
            text += "\n※Completeness is unknown."
        item.setToolTip(text)
        self.result_list.addItem(item) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:22,代码来源:__init__.py

示例2: __undo_redo

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __undo_redo(self) -> None:
        """Undo list settings.

        + Undo stack.
        + Undo view widget.
        + Hot keys.
        """
        self.command_stack = QUndoStack(self)
        self.command_stack.setUndoLimit(self.prefer.undo_limit_option)
        self.command_stack.indexChanged.connect(self.command_reload)
        action_redo = self.command_stack.createRedoAction(self, "Redo")
        action_undo = self.command_stack.createUndoAction(self, "Undo")
        action_redo.setShortcuts(["Ctrl+Shift+Z", "Ctrl+Y"])
        action_redo.setStatusTip("Backtracking undo action.")
        action_redo.setIcon(QIcon(QPixmap(":/icons/redo.png")))
        action_undo.setShortcut("Ctrl+Z")
        action_undo.setStatusTip("Recover last action.")
        action_undo.setIcon(QIcon(QPixmap(":/icons/undo.png")))
        self.menu_edit.addActions([action_undo, action_redo]) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:21,代码来源:main_base.py

示例3: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __init__(
        self,
        env: str,
        file_name: str,
        vpoints: Sequence[VPoint],
        v_to_slvs: Callable[[], Iterable[Tuple[int, int]]],
        parent: QWidget
    ):
        """Comes in environment variable and project name."""
        super(OutputDialog, self).__init__(parent)
        self.setupUi(self)
        self.setWindowFlags(self.windowFlags()
                            & ~Qt.WindowContextHelpButtonHint)
        self.setWindowTitle(f"Export {self.format_name} module project")
        self.setWindowIcon(QIcon(QPixmap(f":/icons/{self.format_icon}")))
        self.assembly_label.setText(self.assembly_description)
        self.frame_label.setText(self.frame_description)
        self.path_edit.setPlaceholderText(env)
        self.filename_edit.setPlaceholderText(file_name)
        self.vpoints = vpoints
        self.v_to_slvs = v_to_slvs 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:23,代码来源:output_option.py

示例4: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __init__(self):
        super(Restarter, self).__init__()
        self.ellipsis = ['', '.', '..', '...', '..', '.']

        # Widgets
        self.timer_ellipsis = QTimer(self)
        self.splash = QSplashScreen(QPixmap(get_image_path(
                                        'Tellurium_splash.png'), 'png'))

        # Widget setup
        self.setVisible(False)

        font = self.splash.font()
        font.setPixelSize(10)
        self.splash.setFont(font)
        self.splash.show()

        self.timer_ellipsis.timeout.connect(self.animate_ellipsis) 
开发者ID:sys-bio,项目名称:tellurium,代码行数:20,代码来源:restart.py

示例5: icon

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def icon(self, name: str):
        """ get an icon with the given filename """
        pm = QtGui.QPixmap(os.path.join(os.path.dirname(__file__), "icons", name))
        if hasattr(pm, 'setDevicePixelRatio'):
            pm.setDevicePixelRatio(self.canvas._dpi_ratio)
        return QtGui.QIcon(pm) 
开发者ID:rgerum,项目名称:pylustrator,代码行数:8,代码来源:QComplexWidgets.py

示例6: square_pixmap

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def square_pixmap(size):
    """Create a white/black hollow square pixmap. For use as labels cursor."""
    pixmap = QPixmap(QSize(size, size))
    pixmap.fill(Qt.transparent)
    painter = QPainter(pixmap)
    painter.setPen(Qt.white)
    painter.drawRect(0, 0, size - 1, size - 1)
    painter.setPen(Qt.black)
    painter.drawRect(1, 1, size - 3, size - 3)
    painter.end()
    return pixmap 
开发者ID:napari,项目名称:napari,代码行数:13,代码来源:utils.py

示例7: drag_with_pixmap

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def drag_with_pixmap(list_widget: QListWidget) -> QDrag:
    """Create a QDrag object with a pixmap of the currently select list item.

    This method is useful when you have a QListWidget that displays custom
    widgets for each QListWidgetItem instance in the list (usually by calling
    ``QListWidget.setItemWidget(item, widget)``).  When used in a
    ``QListWidget.startDrag`` method, this function creates a QDrag object that
    shows an image of the item being dragged (rather than an empty rectangle).

    Parameters
    ----------
    list_widget : QListWidget
        The QListWidget for which to create a QDrag object.

    Returns
    -------
    QDrag
        A QDrag instance with a pixmap of the currently selected item.

    Example
    -------
    >>> class QListWidget:
    ...     def startDrag(self, supportedActions):
    ...         drag = drag_with_pixmap(self)
    ...         drag.exec_(supportedActions, Qt.MoveAction)

    """
    drag = QDrag(list_widget)
    drag.setMimeData(list_widget.mimeData(list_widget.selectedItems()))
    size = list_widget.viewport().visibleRegion().boundingRect().size()
    pixmap = QPixmap(size)
    pixmap.fill(Qt.transparent)
    painter = QPainter(pixmap)
    for index in list_widget.selectedIndexes():
        rect = list_widget.visualRect(index)
        painter.drawPixmap(rect, list_widget.viewport().grab(rect))
    painter.end()
    drag.setPixmap(pixmap)
    drag.setHotSpot(list_widget.viewport().mapFromGlobal(QCursor.pos()))
    return drag 
开发者ID:napari,项目名称:napari,代码行数:42,代码来源:utils.py

示例8: setRevisionTableColumn

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def setRevisionTableColumn(self, row, column, value, icon=None, isLongText=False):
        value = str(value)

        widget = QtWidgets.QWidget()
        layout = QtWidgets.QHBoxLayout()
        layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignHCenter)

        # Use a QLineEdit to allow the text to be copied if the data is large
        if isLongText:
            textLabel = QtWidgets.QLineEdit()
            textLabel.setText(value)
            textLabel.setCursorPosition(0)
            textLabel.setReadOnly(True)
            textLabel.setStyleSheet("QLineEdit { border: none }")
        else:
            textLabel = QtWidgets.QLabel(value)
            textLabel.setStyleSheet("QLabel { border: none } ")

        # layout.setContentsMargins(4, 0, 4, 0)
        
        if icon:
            iconPic = QtGui.QPixmap(icon)
            iconPic = iconPic.scaled(16, 16)
            iconLabel = QtWidgets.QLabel()
            iconLabel.setPixmap(iconPic)
            layout.addWidget(iconLabel)
        layout.addWidget(textLabel)

        widget.setLayout(layout)

        self.tableWidget.setCellWidget(row, column, widget) 
开发者ID:TomMinor,项目名称:P4VFX,代码行数:33,代码来源:FileRevisionWindow.py

示例9: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __init__(self):
        super(Q7FileIconProvider, self).__init__()
        self.dir = QIcon(QPixmap(":/images/icons/folder.png"))
        self.cgns = QIcon(QPixmap(":/images/icons/tree-load.png"))
        self.empty = QIcon() 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:7,代码来源:wfile.py

示例10: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __init__(self, parent: MainWindowBase):
        """Create two widget page and using main window to make their parent."""
        super(Collections, self).__init__(parent)
        layout = QVBoxLayout(self)
        self.tab_widget = QTabWidget(self)
        layout.addWidget(self.tab_widget)
        self.setWindowIcon(QIcon(QPixmap(":/icons/collections.png")))
        self.structure_widget = StructureWidget(parent)
        self.configure_widget = ConfigureWidget(
            self.structure_widget.add_collection,
            parent
        )
        self.tab_widget.addTab(
            self.structure_widget,
            self.structure_widget.windowIcon(),
            "Structures"
        )
        self.tab_widget.addTab(
            self.configure_widget,
            self.configure_widget.windowIcon(),
            "Configuration"
        )
        self.structure_widget.configure_button.clicked.connect(
            lambda: self.tab_widget.setCurrentIndex(1)
        )
        self.structure_widget.layout_sender.connect(
            self.configure_widget.set_graph
        ) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:30,代码来源:__init__.py

示例11: __save_graph

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __save_graph(self) -> None:
        """Save the current graph."""
        if self.selection_window.count() != 1:
            return
        file_name = self.output_to("atlas image", qt_image_format)
        if not file_name:
            return
        pixmap: QPixmap = self.selection_window.item(0).icon().pixmap(self.selection_window.iconSize())
        pixmap.save(file_name)
        self.save_reply_box("Graph", file_name) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:12,代码来源:structure_widget.py

示例12: __save_atlas

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __save_atlas(self) -> None:
        """Save function as same as type synthesis widget."""
        count = self.collection_list.count()
        if count < 1:
            return
        lateral, ok = QInputDialog.getInt(
            self,
            "Atlas",
            "The number of lateral:",
            5, 1
        )
        if not ok:
            return
        file_name = self.output_to("atlas image", qt_image_format)
        if not file_name:
            return
        icon_size = self.collection_list.iconSize()
        width = icon_size.width()
        image = self.collection_list.item(0).icon().pixmap(icon_size).toImage()
        image_main = QImage(QSize(
            lateral if count > lateral else count,
            (count // lateral) + bool(count % lateral)
        ) * width, image.format())
        image_main.fill(Qt.transparent)
        painter = QPainter(image_main)
        for row in range(count):
            image = self.collection_list.item(row).icon().pixmap(icon_size).toImage()
            painter.drawImage(QPointF(row % lateral, row // lateral) * width, image)
        painter.end()
        pixmap = QPixmap()
        pixmap.convertFromImage(image_main)
        pixmap.save(file_name)
        self.save_reply_box("Atlas", file_name) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:35,代码来源:structure_widget.py

示例13: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __init__(
        self,
        vpoints: List[VPoint],
        vlinks: List[VLink],
        row: Union[int, bool],
        parent: QWidget
    ):
        """Input data reference from main window.

        + Needs VPoints and VLinks information.
        + If row is false: Create action.
        """
        super(EditLinkDialog, self).__init__(parent)
        self.setupUi(self)
        self.setWindowFlags(self.windowFlags()
                            & ~Qt.WindowContextHelpButtonHint)
        self.vpoints = vpoints
        self.vlinks = vlinks
        icon = self.windowIcon()
        self.icon = QIcon(QPixmap(":/icons/bearing.png"))
        for i, e in enumerate(color_names):
            self.color_box.insertItem(i, color_icon(e), e)
        for i in range(len(self.vpoints)):
            self.no_selected.addItem(QListWidgetItem(self.icon, f'Point{i}'))
        if row is False:
            names = {vlink.name for vlink in self.vlinks}
            n = 1
            name = f"link_{n}"
            while name in names:
                n += 1
                name = f"link_{n}"
            self.name_edit.setText(name)
            self.name_box.setEnabled(False)
            self.name_box.addItem(icon, "New link")
            self.color_box.setCurrentIndex(self.color_box.findText('blue'))
        else:
            for i, vlink in enumerate(self.vlinks):
                self.name_box.insertItem(i, icon, vlink.name)
            self.name_box.setCurrentIndex(row)
        self.name_edit.textChanged.connect(self.__is_ok)
        self.__is_ok() 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:43,代码来源:edit_link.py

示例14: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def __init__(
        self,
        vpoints: List[VPoint],
        vlinks: List[VLink],
        pos: Union[int, bool],
        parent: QWidget
    ):
        """Input data reference from main window.

        + Needs VPoints and VLinks information.
        + If row is false: Create action.
        """
        super(EditPointDialog, self).__init__(parent)
        self.setupUi(self)
        self.setWindowFlags(self.windowFlags()
                            & ~Qt.WindowContextHelpButtonHint)
        icon = self.windowIcon()
        self.icon = QIcon(QPixmap(":/icons/link.png"))
        self.vpoints = vpoints
        self.vlinks = vlinks
        vpoints_count = len(vpoints)
        for i, e in enumerate(color_names):
            self.color_box.insertItem(i, color_icon(e), e)
        for vlink in vlinks:
            self.no_selected.addItem(QListWidgetItem(self.icon, vlink.name))
        if pos is False:
            self.name_box.addItem(icon, f'Point{vpoints_count}')
            self.name_box.setEnabled(False)
            self.color_box.setCurrentIndex(self.color_box.findText('green'))
        else:
            for i in range(vpoints_count):
                self.name_box.insertItem(i, icon, f'Point{i}')
            self.name_box.setCurrentIndex(pos)
        self.type_box.currentIndexChanged.connect(self.__check_angle)
        self.__check_angle() 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:37,代码来源:edit_point.py

示例15: redo

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QPixmap [as 别名]
def redo(self) -> None:
        """Add mechanism expression to 'expr' attribute."""
        item = QListWidgetItem(self.name)
        item.expr = self.mechanism
        item.setIcon(QIcon(QPixmap(":/icons/mechanism.png")))
        self.widget.addItem(item) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:8,代码来源:undo_redo.py


注:本文中的qtpy.QtGui.QPixmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。