本文整理匯總了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)