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


Python QtWidgets.QGraphicsItem方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def __init__(self, parent):
        """
        Create property animations, sets the opacity to zero initially.

        :param parent:
        """
        super().__init__()
        if isinstance(parent, QtWidgets.QGraphicsItem):
            # create opacity effect
            self.effect = QtWidgets.QGraphicsOpacityEffect()
            self.effect.setOpacity(0)
            parent.setGraphicsEffect(self.effect)
            self.fade = QtCore.QPropertyAnimation(self.effect, 'opacity'.encode())  # encode is utf-8 by default
        elif isinstance(parent, QtWidgets.QWidget):
            parent.setWindowOpacity(0)
            self.fade = QtCore.QPropertyAnimation(parent, 'windowOpacity'.encode())  # encode is utf-8 by default
        else:
            raise RuntimeError('Type of parameter must be QtWidgets.QGraphicsItem or QtWidgets.QWidget.')

        # set start and stop value
        self.fade.setStartValue(0)
        self.fade.setEndValue(1)
        self.fade.finished.connect(self.finished)

        self.forward = True 
开发者ID:Trilarion,项目名称:imperialism-remake,代码行数:27,代码来源:qt.py

示例2: itemChange

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def itemChange(self, change, value):
        """
        Handle movement
        """
        if change == QtWidgets.QGraphicsItem.ItemPositionChange:
            if self.scene() is None: return value

            updRect = QtCore.QRectF(
                self.x() + self.aux.x(),
                self.y() + self.aux.y(),
                self.aux.BoundingRect.width(),
                self.aux.BoundingRect.height(),
            )
            self.scene().update(updRect)

        return super().itemChange(change, value) 
开发者ID:aboood40091,项目名称:Miyamoto,代码行数:18,代码来源:items.py

示例3: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def __init__(self, parent, imageObj):
        """
        Generic constructor for auxiliary zone items
        """
        super().__init__(parent)
        self.parent = parent
        self.imageObj = imageObj
        self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
        self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
        self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, False)
        self.setParentItem(parent)
        self.hover = False

        if parent is not None:
            parent.aux.add(self)

        self.BoundingRect = QtCore.QRectF(0, 0, TileWidth, TileWidth) 
开发者ID:aboood40091,项目名称:Miyamoto,代码行数:19,代码来源:spritelib.py

示例4: _on_element_selected

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def _on_element_selected(self, element: Optional[qw.QGraphicsItem], mouse_pos: qc.QPointF):
        text = f'mouse position: {mouse_pos.x():.4f}, {mouse_pos.y():.4f}\n'
        if element is None:
            text += 'No element selected'
        else:
            dxf_entity = element.data(CorrespondingDXFEntity)
            if dxf_entity is None:
                text += 'No data'
            else:
                text += f'Current Entity: {dxf_entity}\nLayer: {dxf_entity.dxf.layer}\n\nDXF Attributes:\n'
                for key, value in dxf_entity.dxf.all_existing_dxf_attribs().items():
                    text += f'- {key}: {value}\n'

                dxf_entity_stack = element.data(CorrespondingDXFEntityStack)
                if dxf_entity_stack:
                    text += '\nParents:\n'
                    for entity in reversed(dxf_entity_stack):
                        text += f'- {entity}\n'

        self.info.setPlainText(text) 
开发者ID:mozman,项目名称:ezdxf,代码行数:22,代码来源:cad_viewer.py

示例5: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def __init__(self):
        QtWidgets.QGraphicsRectItem.__init__(self, self.cursor)
        self.setPen(self.pen)
        self.setZValue(1e9)
        self.setFlag(QtWidgets.QGraphicsItem.ItemIgnoresTransformations) 
开发者ID:pyrocko,项目名称:kite,代码行数:7,代码来源:multiplot.py

示例6: add_item

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def add_item(self, item: QtWidgets.QGraphicsItem):
        """
        Adds an item to the content list. Should be

        :param item:
        """
        if not isinstance(item, QtWidgets.QGraphicsItem):
            raise RuntimeError('Expected instance of QGraphicsItem!')
        self._content.add(item) 
开发者ID:Trilarion,项目名称:imperialism-remake,代码行数:11,代码来源:qt.py

示例7: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def __init__(self, parent):
            """
            Initializes the auxiliary entrance thing
            """
            super().__init__(parent)
            self.parent = parent
            self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
            self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
            self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, True)
            self.setParentItem(parent)
            self.hover = False 
开发者ID:aboood40091,项目名称:Miyamoto,代码行数:13,代码来源:items.py

示例8: setIsBehindZone

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def setIsBehindZone(self, behind):
        """
        This allows you to choose whether the auiliary item will display
        behind the zone or in front of it. Default is for the item to
        be in front of the zone.
        """
        self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, behind) 
开发者ID:aboood40091,项目名称:Miyamoto,代码行数:9,代码来源:spritelib.py

示例9: setIsBehindLocation

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def setIsBehindLocation(self, behind):
        """
        This allows you to choose whether the auiliary item will display
        behind the zone or in front of it. Default is for the item to
        be in front of the location.
        """
        self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, behind) 
开发者ID:aboood40091,项目名称:Miyamoto,代码行数:9,代码来源:spritelib.py

示例10: setPos

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def setPos(self, *__args):
        """
        Set the item position.
        QtWidgets.QGraphicsItem.setPos(QtCore.QPointF)
        QtWidgets.QGraphicsItem.setPos(float, float)
        """
        if len(__args) == 1:
            pos = __args[0]
        elif len(__args) == 2:
            pos = QtCore.QPointF(__args[0], __args[1])
        else:
            raise TypeError('too many arguments; expected {0}, got {1}'.format(2, len(__args)))
        super().setPos(pos - QtCore.QPointF(self.width() / 2, self.height() / 2)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:15,代码来源:common.py

示例11: addItem

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def addItem(self, item: QGraphicsItem) -> None:
        super(ImageViewerScene, self).addItem(item)
        if isinstance(item, EditableItem):
            self.itemAdded.emit(item) 
开发者ID:haruiz,项目名称:CvStudio,代码行数:6,代码来源:image_viewer_scene.py

示例12: removeItem

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def removeItem(self, item: QGraphicsItem) -> None:
        super(ImageViewerScene, self).removeItem(item)
        if isinstance(item, EditableItem):
            self.itemDeleted.emit(item) 
开发者ID:haruiz,项目名称:CvStudio,代码行数:6,代码来源:image_viewer_scene.py

示例13: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def __init__(self):
        super().__init__()
        self._current_item: Optional[qw.QGraphicsItem] = None 
开发者ID:mozman,项目名称:ezdxf,代码行数:5,代码来源:cad_viewer.py

示例14: _set_item_data

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def _set_item_data(self, item: qw.QGraphicsItem) -> None:
        item.setData(CorrespondingDXFEntity, self.current_entity)
        item.setData(CorrespondingDXFEntityStack, self.current_entity_stack) 
开发者ID:mozman,项目名称:ezdxf,代码行数:5,代码来源:pyqt_backend.py

示例15: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
def __init__(self, node, parent = None, scene = None):
		super(SymbolUIItem, self).__init__(parent, scene)
		isIgnore = node and node.getKind() == node.KIND_UNKNOWN
		self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, not isIgnore)
		self.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable, not isIgnore)
		self.setAcceptDrops(True);
		self.setAcceptHoverEvents(True)
		self.node = node
		self.path = None
		self.rect = None
		self.isHover = False
		self.theta = (0,0)
		self.radius= (0,0)
		self.txtRadius = 0
		self.setToolTip("%s:%s" % (node.name, node.getKindName()))
		self.txtPos = None

		if not SymbolUIItem.COLOR_DICT:
			SymbolUIItem.COLOR_DICT = \
				{self.node.KIND_FUNCTION: QtGui.QColor(190,228,73),
				 self.node.KIND_VARIABLE: QtGui.QColor(255,198,217),
				 self.node.KIND_CLASS:    QtGui.QColor(154,177,209),
				 self.node.KIND_NAMESPACE: QtGui.QColor(154,225,209),
				 self.node.KIND_UNKNOWN: QtGui.QColor(195,195,195),
				 }

		self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable)
		self.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable) 
开发者ID:league1991,项目名称:CodeAtlasSublime,代码行数:30,代码来源:SymbolUIItem.py


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