本文整理汇总了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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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)
示例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))
示例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)
示例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)
示例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
示例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)
示例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)