本文整理汇总了Python中PyQt4.QtGui.QGraphicsItem类的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsItem类的具体用法?Python QGraphicsItem怎么用?Python QGraphicsItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QGraphicsItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseReleaseEvent
def mouseReleaseEvent (self, e):
self.harpoon.setVisible (False)
self.helper.initAndStartTimer ()
QGraphicsItem.mouseReleaseEvent (self, e)
示例2: __init__
def __init__(self, scale, source, target, parent=None):
QGraphicsItem.__init__(self, parent)
self.source = source
self.target = target
self.scale = scale
self.updateShape()
self.setZValue(2)
示例3: mousePressEvent
def mousePressEvent (self, e):
self.harpoon.setInitPos (self.pos()+self.parent.pos())
self.harpoon.setVisible (True)
self.harpoon.update ()
QGraphicsItem.mousePressEvent (self, e)
示例4: __init__
def __init__(self, scene, axis, posModel):
"""
scene: Must be an ImageScene2D instance. We manipulate the scene.allow_brushing flag.
"""
QGraphicsItem.__init__(self, scene=scene)
self.setFlag(QGraphicsItem.ItemHasNoContents);
self.axis = axis
self.posModel = posModel
self._width = 0
self._height = 0
self.thick_penX = QPen(Qt.red, self.thick_width)
self.thick_penX.setCosmetic(True)
self.thick_penY = QPen(Qt.green, self.thick_width)
self.thick_penY.setCosmetic(True)
self.thin_penX = QPen(Qt.red, self.thin_width)
self.thin_penX.setCosmetic(True)
self.thin_penY = QPen(Qt.green, self.thin_width)
self.thin_penY.setCosmetic(True)
self.x = 0
self.y = 0
# These child items do most of the work.
self._horizontal_marker = SliceMarkerLine(self, 'horizontal')
self._vertical_marker = SliceMarkerLine(self, 'vertical')
示例5: __init__
def __init__(self, scene, axis, crop_extents_model, editable=True):
self._cropColor = Qt.white
self._editable = editable
QGraphicsItem.__init__(self, scene=scene)
self.setFlag(QGraphicsItem.ItemHasNoContents);
self.setAcceptHoverEvents(True)
self.scene = scene
self.axis = axis
self.crop_extents_model = crop_extents_model
self.crop_extents_model.editableChanged.connect( self.onEditableChanged)
self._width = 0
self._height = 0
# Add shading item first so crop lines are drawn on top.
self._shading_item = ExcludedRegionShading( self, self.crop_extents_model )
self._horizontal0 = CropLine(self, 'horizontal', 0)
self._horizontal1 = CropLine(self, 'horizontal', 1)
self._vertical0 = CropLine(self, 'vertical', 0)
self._vertical1 = CropLine(self, 'vertical', 1)
self.crop_extents_model.changed.connect( self.onExtentsChanged )
self.crop_extents_model.colorChanged.connect( self.onColorChanged )
# keeping track which line started mouse move
self._mouseMoveStartH = -1
self._mouseMoveStartV = -1
self._fractionOfDistance = 1
示例6: __init__
def __init__(self, scene, axis, posModel):
QGraphicsItem.__init__(self, scene=scene)
self.setFlag(QGraphicsItem.ItemHasNoContents);
self.axis = axis
self.posModel = posModel
self._width = 0
self._height = 0
self.thick_penX = QPen(Qt.red, self.thick_width)
self.thick_penX.setCosmetic(True)
self.thick_penY = QPen(Qt.green, self.thick_width)
self.thick_penY.setCosmetic(True)
self.thin_penX = QPen(Qt.red, self.thin_width)
self.thin_penX.setCosmetic(True)
self.thin_penY = QPen(Qt.green, self.thin_width)
self.thin_penY.setCosmetic(True)
self.x = 0
self.y = 0
# These child items do most of the work.
self._horizontal_marker = SliceMarkerLine(self, 'horizontal')
self._vertical_marker = SliceMarkerLine(self, 'vertical')
# We
self._horizontal_marker = SliceMarkerLine(self, 'horizontal')
self._vertical_marker = SliceMarkerLine(self, 'vertical')
示例7: __init__
def __init__(self, unit):
QGraphicsItem.__init__(self)
self.unit = unit
self.yPosition = unit * 0.03
self.width = -self.unit * 0.02
self.lengthInUnits = 200
self.axisLength = self.lengthInUnits * unit
self.axisStart = -self.axisLength / 2
示例8: __init__
def __init__(self, tile):
QGraphicsItem.__init__(self)
self._tile = weakref.ref(tile) # avoid circular references for easier gc
self._boundingRect = None
self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
# while moving the tile we use ItemCoordinateCache, see
# Tile.setActiveAnimation
self.setClippingFlags()
示例9: hoverLeaveEvent
def hoverLeaveEvent (self, e):
self.pen_color = QPen (Qt.black, 2)
self._text_item.setDefaultTextColor (Qt.black)
# records the node_id in the helper's attribute.
self.comm.setHoveredSocketId (None)
QGraphicsItem.hoverLeaveEvent (self, e)
示例10: __init__
def __init__(self):
QGraphicsItem.__init__(self)
self.__selected = None
self.setZValue(3.0)
self.__mark = EDraw.Circle(10, 3, 90).translated(QPointF(0.0, -12.0))
self.__pen = EDraw.EColor.DefaultEnterHoverPen
示例11: addItem
def addItem(self, QGraphicsItem):
if self.__isNode(QGraphicsItem):
QGraphicsItem.setZValue(1.0)
QGraphicsItem.onPress.connect(self.__onNodePressed)
self.__nodes[QGraphicsItem.Id] = QGraphicsItem
QGraphicsScene.addItem(self, QGraphicsItem)
示例12: hoverLeaveEvent
def hoverLeaveEvent (self, e):
# records the node_id in the helper's attribute.
self.comm.setHoveredItemId (None)
# deal with the harpoon.
if not self.helper.isTimerEnded():
self.setSelected (True)
QGraphicsItem.hoverLeaveEvent (self, e)
示例13: mousePressEvent
def mousePressEvent (self, e):
#self.setAcceptedMouseButtons(Qt.NoButton)
self.previousMouseGrabberItem = self.scene.mouseGrabberItem()
if e.button() == Qt.RightButton:
pos = self.pos()
self.comm.emitCtxMenuSignal (pos)
QGraphicsItem.mousePressEvent (self, e)
示例14: __init__
def __init__(self, parent, direction, index):
assert isinstance(parent, CroppingMarkers)
assert direction in ('horizontal', 'vertical')
self._parent = parent
self._direction = direction
self._index = index
QGraphicsItem.__init__(self, parent)
self.setAcceptHoverEvents(True)
self._position = 0
示例15: __init__
def __init__(self, parent=None, graphicView=None, graphicScene=None):
QGraphicsItem.__init__(self)
self.set_default_data()
self.className = QGraphicsTextItem(self)
self.functionsItem = FunctionsContainerModel(self)
self.className.setPlainText(self.defaultClassName)
self.setFlag(self.ItemIsMovable)
self.setFlag(self.ItemSendsGeometryChanges)
self.functionsItem.setPos(0, self.__get_title_height())
self.attributesItem = FunctionsContainerModel(self)
self.attributesItem.setPos(0, self.functionsItem.get_height())