本文整理汇总了Python中PyQt4.QtGui.QGraphicsEllipseItem类的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsEllipseItem类的具体用法?Python QGraphicsEllipseItem怎么用?Python QGraphicsEllipseItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QGraphicsEllipseItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.outerD = 125
self.innerD = 25
self.innerRange = 50
self.inputRange = 256
self.thresh = 3
self.worker = JoystickThread()
self.worker.valueUpdated.connect(self.moveJoystick)
self.worker.start()
self.move(30, 100)
self.setContentsMargins(0, 0, 0, 0)
self.setMaximumHeight(140)
self.setMaximumWidth(140)
self.adjustSize()
self.scene = QGraphicsScene(self)
self.outerCircle = QGraphicsEllipseItem(0, 0, self.outerD, self.outerD)
self.outerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle.setBrush(Qt.gray)
self.innerCircle = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2, self.innerD, self.innerD)
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle)
self.scene.addItem(self.innerCircle)
self.setScene(self.scene)
self.setStyleSheet('background-color:transparent;color:red')
self.currentX = 0
self.currentY = 0
示例2: point
def point(scene, x, y, color='black', fill='black', diam=10, toolTip=None):
item = QGraphicsEllipseItem(x-diam/2, y-diam/2, diam, diam)
brush = QBrush(QColor(color), style=Qt.SolidPattern)
item.setBrush(brush)
if toolTip:
item.setToolTip(toolTip)
scene.addItem(item)
示例3: GPendulum
class GPendulum(Graphics.Items.ItemGroupBase):
def _setup(self):
self.rod = QGraphicsLineItem(QLineF(0, 0, 0, 100))
p = QPen(QColor(100, 100, 100))
p.setWidth(5)
self.rod.setPen(p)
self.rod.setToolTip('This is the rod of the pendulum')
self.ball = QGraphicsEllipseItem(QRectF(-20, 80, 40, 40))
b = QBrush(Qt.SolidPattern)
b.setColor(QColor(0, 255, 0))
self.ball.setBrush(b)
self.ball.setToolTip('This is the ball of the pendulum where the mass is concentrated')
self.addToGroup(self.rod)
self.addToGroup(self.ball)
self.setFlags(QGraphicsItem.ItemIsSelectable)
def setProperties(self, q):
self.properties = q
def contextMenuEvent(self, e):
e.accept()
m = QMenu()
p = m.addAction("Properties")
a = m.exec_(e.screenPos())
if a == p:
dlg = SimTools.RichTypes.Qt4Widgets.SimpleRichTypesDialog(mainWin, 'Pendulum properties',
text='Change physical properties', scrolling=False)
dlg.addRichTypes(self.properties)
dlg.exec_()
示例4: __init__
def __init__(self, *args):
QGraphicsEllipseItem.__init__(self, *args)
self.setRect(-3, -3, 6, 6)
self.setPen(QPen(Qt.NoPen))
self.normalBrush = QBrush(QColor("#9CACB4"))
self.hoverBrush = QBrush(QColor("#7D7D7D"))
self.setBrush(self.normalBrush)
self.__hover = False
示例5: __init__
def __init__(self, rect, type):
QGraphicsEllipseItem.__init__(self, rect)
self._color = None
self._darkColor = None
self._pos = None
self._startAngle = None
self._spanAngle = None
self._value = None
self._type = type
示例6: __init__
def __init__(self, name, tileset, roundsFinished=0, parent = None):
"""generate new wind tile"""
if not len(WINDPIXMAPS):
WINDPIXMAPS[('E', False)] = None # avoid recursion
self.genWINDPIXMAPS()
QGraphicsEllipseItem.__init__(self)
if parent:
self.setParentItem(parent)
self.name = name
self.face = QGraphicsSvgItem()
self.face.setParentItem(self)
self.prevailing = None
self.setWind(name, roundsFinished)
self.tileset = tileset
self.__sizeFace()
示例7: __init__
def __init__(self, rect=None):
super(TaskGraphicsItem, self).__init__()
if rect is not None:
self.setRect(rect)
self.setPen(QPen(Qt.NoPen))
# Setup the text item
self.textItem = QGraphicsTextItem()
self.textItem.setParentItem(self)
self.textItem.rotate(-90)
self.textItem.setDefaultTextColor(QColor(255, 255, 255))
# The dimensions to reach via a LERP.
self.startPos = QPointF(0, 0)
self.endPos = QPointF(0, 0)
self.startDiameter = 1
self.endDiameter = 1
self.centerMark = QGraphicsEllipseItem()
self.centerMark.setBrush(QBrush(Qt.white))
self.centerMark.setPen(QPen(Qt.NoPen))
self.centerMark.setParentItem(self)
self.pid = -1
# To determine if it is associated with an active process.
self.used = False
示例8: __init__
def __init__(self, outer, inner, filename=None, width=None, height=None, x=0, y=0, pixmap=None, group=None, pos=None, size=None, padding=None):
Button.__init__(self, filename, width, height, x, y, pixmap, group, pos, size, padding)
self.outer = outer
self.inner = inner
self.innerRange = 48
self.inputRange = 256
self.thresh = 5
self.outerCircle = QGraphicsEllipseItem(self.getX(), self.getY(), self.outer, self.outer)
self.outerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle.setBrush(Qt.gray)
self.innerCircle = QGraphicsEllipseItem(self.getX() + self.outer / 2 - self.inner / 2, self.getY() + self.outer / 2 - self.inner / 2, self.inner, self.inner)
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.currentX = 0
self.currentY = 0
self.items = [self.outerCircle, self.innerCircle]
示例9: __init__
def __init__(self, pen=QPen(Qt.black), brush=QBrush(Qt.NoBrush), xCenter=0.0, yCenter=0.0, radius=1.0):
OWCurve.__init__(self)
self._item = QGraphicsEllipseItem(self)
self.center = xCenter, yCenter
self.radius = radius
self._rect = QRectF(xCenter - radius, yCenter - radius, 2 * radius, 2 * radius)
self.set_pen(pen)
self.set_brush(brush)
示例10: __init__
def __init__(self, longitude, latitude, pixmap, scene, parent=None):
"""Constructor.
Args:
longitude(float): Longitude of the origin of the pixmap.
latitude(float): Latitude of the center of the pixmap.
pixmap(QPixmap): Pixmap.
scene(MapGraphicsScene): Scene the item belongs to.
parent(QGraphicsItem): Parent item.
"""
QGraphicsEllipseItem.__init__(self, parent=parent, scene=scene)
self._lon = longitude
self._lat = latitude
self.setPixmap(pixmap)
self.updatePosition(scene)
示例11: __init__
def __init__(self, radius, parent=None):
QGraphicsEllipseItem.__init__(self, QRectF(-radius, -radius, radius*2.0, radius*2.0), parent=parent)
self._pen = QPen(QColor('#000000'))
self._pen.setWidth(1)
self.setPen(self._pen)
self._hoverPen = QPen(QColor('#000000'))
self._hoverPen.setWidth(2)
brush = QBrush(QColor('#FF9966'))
self.setBrush(brush)
self._isSelected = False
self._isHover = False
self.setAcceptHoverEvents(True)
示例12: __init__
def __init__(self, p0, p1, parent=None):
QGraphicsPathItem.__init__(self, parent=parent)
self._p0 = p0
self._p1 = p1
self._startPoint = QGraphicsEllipseItem(-3, -3, 6, 6, parent=self)
self._startPoint.setPos(p0)
self._endPoint = QGraphicsEllipseItem(-3, -3, 6, 6, parent=self)
self._endPoint.setVisible(False)
brush = QBrush(QColor(Qt.black))
self._startPoint.setBrush(brush)
self._endPoint.setBrush(brush)
pen = QPen(brush, 2.0)
self.setPen(pen)
示例13: _finish_select_area
def _finish_select_area(self):
self.unregister_handler(self.home_map_scene,
QEvent.GraphicsSceneMouseRelease)
self.unregister_handler(self.home_map_scene,
QEvent.KeyRelease)
item = None
for id,it in self.current_op_stat['items'].items() :
print "%d,%s" % (id,HMItem.repr(it))
p = it.polygon().first()
item = None
self.current_op = ''
self.current_op_stat = None
el_it = QGraphicsEllipseItem(p.x()-2,p.y()-2,4,4)
HMItem.module(el_it,self.__class__.__name__)
HMItem.type(el_it,HMItem.ARTIFACT)
HMItem.level(el_it, -1)
el_it.setPen(QPen(Qt.blue,
1,
Qt.SolidLine,
Qt.RoundCap,
Qt.RoundJoin))
el_it.setBrush(QBrush(Qt.blue))
el_it.setZValue(1)
self.home_map_scene.addItem(el_it)
示例14: ugly_name_face
def ugly_name_face(node, *args, **kargs):
""" This is my item generator. It must receive a node object, and
returns a Qt4 graphics item that can be used as a node face.
"""
# receive an arbitrary number of arguments, in this case width and
# height of the faces
width = args[0][0]
height = args[0][1]
## Creates a main master Item that will contain all other elements
## Items can be standard QGraphicsItem
# masterItem = QGraphicsRectItem(0, 0, width, height)
# Or your custom Items, in which you can re-implement interactive
# functions, etc. Check QGraphicsItem doc for details.
masterItem = InteractiveItem(0, 0, width, height)
# Keep a link within the item to access node info
masterItem.node = node
# I dont want a border around the masterItem
masterItem.setPen(QPen(QtCore.Qt.NoPen))
# Add ellipse around text
ellipse = QGraphicsEllipseItem(masterItem.rect())
ellipse.setParentItem(masterItem)
# Change ellipse color
ellipse.setBrush(QBrush(QColor( random_color())))
# Add node name within the ellipse
text = QGraphicsSimpleTextItem(node.name)
text.setParentItem(ellipse)
text.setPen(QPen(QPen(QColor("white"))))
# Center text according to masterItem size
tw = text.boundingRect().width()
th = text.boundingRect().height()
center = masterItem.boundingRect().center()
text.setPos(center.x()-tw/2, center.y()-th/2)
return masterItem
示例15: iLabel
def iLabel(node, *args, **kargs):
#code for making specialized faces for intermediates mostly cribbed from the ete2 website example (though not interactive):
# http://pythonhosted.org/ete2/tutorial/tutorial_drawing.html#creating-your-custom-interactive-item-faces
my_label = node.name
ellipse = QGraphicsEllipseItem(0,0,fontSize*2,fontSize*2) #I think the first two are coords of center; second pair is major/minor axis
ellipse.setPen(QPen(QColor( 'black' )))
ellipse.setBrush(QBrush(QColor( 'white' )))
text = QGraphicsSimpleTextItem(my_label)
text.setParentItem(ellipse)
text.setBrush(QBrush(QColor("black")))
font = QFont("Arial",fontSize*.9,weight=80)
font.setLetterSpacing(1, 2) #add 2 pixels between letters for legibility
text.setFont(font)
#Center text according to masterItem size
tw = text.boundingRect().width()
th = text.boundingRect().height()
center = ellipse.boundingRect().center()
text.setPos(center.x()+1-tw/2, center.y()-th/2) #since the last letter has an extra 2 pixels after it from the spacing command, adjust center to compensate
return ellipse