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


Python QGraphicsLineItem.setPen方法代码示例

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


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

示例1: draw_y_axis

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
 def draw_y_axis(self):
     lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0]),
                                  0, self.coordY(self.ylim[1]),
                                  parent=self.item)
     lineItem.setPen(QPen(QColor('black')))
     lineItem.setZValue(10)
     max_w = 0
     for y in set(self.hlines + list(self.ylim)):
         lineItem = QGraphicsLineItem(0, self.coordY(y),
                                            -5, self.coordY(y),
                                            parent=self.item)
         lineItem.setPen(QPen(QColor('black')))
         lineItem.setZValue(10)
         text = QGraphicsSimpleTextItem(str(y))
         text.setFont(QFont("Arial", self.fsize-2))
         text.setParentItem(self.item)
         tw = text.boundingRect().width()
         max_w = tw if tw > max_w else max_w
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-tw - 5, self.coordY(y)-th/2)
     if self.ylabel:
         text = QGraphicsSimpleTextItem(self.ylabel)
         text.setFont(QFont("Arial", self.fsize-1))
         text.setParentItem(self.item)
         text.rotate(-90)
         tw = text.boundingRect().width()
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-th -5-max_w, tw/2+self.coordY(sum(self.ylim)/2))
开发者ID:meren,项目名称:ebov,代码行数:32,代码来源:rulerface.py

示例2: mouseMoveEvent

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:

            downPos = event.buttonDownPos(Qt.LeftButton)
            if not self.__tmpLine and self.__dragStartItem and \
                    (downPos - event.pos()).manhattanLength() > \
                        QApplication.instance().startDragDistance():
                # Start a line drag
                line = QGraphicsLineItem(self)
                start = self.__dragStartItem.boundingRect().center()
                start = self.mapFromItem(self.__dragStartItem, start)
                line.setLine(start.x(), start.y(),
                             event.pos().x(), event.pos().y())

                pen = QPen(Qt.black, 4)
                pen.setCapStyle(Qt.RoundCap)
                line.setPen(pen)
                line.show()

                self.__tmpLine = line

            if self.__tmpLine:
                # Update the temp line
                line = self.__tmpLine.line()
                line.setP2(event.pos())
                self.__tmpLine.setLine(line)

        QGraphicsWidget.mouseMoveEvent(self, event)
开发者ID:Micseb,项目名称:orange3,代码行数:30,代码来源:editlinksdialog.py

示例3: GPendulum

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
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_()
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:31,代码来源:pendulum.py

示例4: draw_errors

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
 def draw_errors(self, x, i):
     lower = self.values[i]+self._dw_err[i]
     upper = self.values[i]+self._up_err[i]
     lineItem = QGraphicsLineItem(0, self.coordY(lower), 0,
                                        self.coordY(upper), parent=self.item)
     lineItem.setX(x)
     lineItem.setPen(QPen(QColor('black'),1))
开发者ID:meren,项目名称:ebov,代码行数:9,代码来源:rulerface.py

示例5: CrossX

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
class CrossX(ItemGroupBase):
    """a cross (x) made of two lines"""
    def _setup(self, x=0, y=0, size=10, pen=QPen(QColor(0,0, 255))):
        a = 0.5*size
        self.p1 = QGraphicsLineItem(QLineF(x-a, y-a, x+a, y+a))
        self.p2 = QGraphicsLineItem(QLineF(x-a, y+a, x+a, y-a))
        self.p1.setPen(pen)
        self.p2.setPen(pen)
        self.addToGroup(self.p1)
        self.addToGroup(self.p2)
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:12,代码来源:Items.py

示例6: onEdgeAdd

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
 def onEdgeAdd(start,end):
   '''
   Whenever a new edge is added to model, this method is to be notified.
   '''
   p1 = nodeToScene[start].rect().center()
   p2 = nodeToScene[end]  .rect().center()
   line = QGraphicsLineItem( QLineF(p1,p2) )
   line.setPen( QPen( QColor(32,32,32), 1 ) )
   groupEdges.addToGroup(line)
   nodeToLineP1[start].add(line)
   nodeToLineP2  [end].add(line)
开发者ID:DirkToewe,项目名称:strandbeest_sim,代码行数:13,代码来源:Strandbeest.py

示例7: Axes

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
class Axes(ItemGroupBase):
    """two rectangular lines as axes"""
    def _setup(self, x=[0, -100, 100], y=[0, -100, 100], pen=QPen(QColor(255,0,0))):
        if x:
            self.xAxis = QGraphicsLineItem(QLineF(x[1], x[0], x[2], x[0]))
            self.xAxis.setPen(pen)
            self.addToGroup(self.xAxis)
        if y:
            self.yAxis = QGraphicsLineItem(QLineF(y[0], y[1], y[0], y[2]))
            self.yAxis.setPen(pen)
            self.addToGroup(self.yAxis)
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:13,代码来源:Items.py

示例8: draw_curve

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
 def draw_curve(self, x, y, i):
     # top line
     lineItem = QGraphicsLineItem(0, self.coordY(y), 4,
                                        self.coordY(y), parent=self.item)
     lineItem.setX(x-2)
     lineItem.setPen(QPen(QColor(self.colors[i]),2))
     if i > 0:
         prev = self.values[i-1] if i>0 else self.values[i]
         lineItem = QGraphicsLineItem(0, self.coordY(prev), self.col_w-4,
                                            self.coordY(y), parent=self.item)
         lineItem.setX(x - self.col_w+2)
         lineItem.setPen(QPen(QColor(self.colors[i]),2))
开发者ID:meren,项目名称:ebov,代码行数:14,代码来源:rulerface.py

示例9: onMouseMove_draw

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
    def onMouseMove_draw( self, imageview, event ):
        self._navIntr.onMouseMove_default( imageview, event )

        o = imageview.scene().data2scene.map(QPointF(imageview.oldX,imageview.oldY))
        n = imageview.scene().data2scene.map(QPointF(imageview.x,imageview.y))

        # Draw temporary line for the brush stroke so the user gets feedback before the data is really updated.
        pen = QPen( QBrush(self._brushingCtrl._brushingModel.drawColor), self._brushingCtrl._brushingModel.brushSize, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
        line = QGraphicsLineItem(o.x(), o.y(), n.x(), n.y())
        line.setPen(pen)
        
        imageview.scene().addItem(line)
        line.setParentItem(imageview.scene().dataRect)

        self._lineItems.append(line)
        self._brushingCtrl._brushingModel.moveTo(imageview.mousePos)
开发者ID:JensNRAD,项目名称:volumina,代码行数:18,代码来源:brushingcontroler.py

示例10: addLines

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
    def addLines(self, x, y, w, h, diff, pen):
        if w == 0 or h == 0:
            return

        dist = 20 * diff  # original distance between two lines in pixels
        temp = dist
        canvas = self.canvas
        while temp < w:
            r = QGraphicsLineItem(temp + x, y, temp + x, y + h, None)
            canvas.addItem(r)
            r.setPen(pen)
            temp += dist

        temp = dist
        while temp < h:
            r = QGraphicsLineItem(x, y + temp, x + w, y + temp, None)
            canvas.addItem(r)
            r.setPen(pen)
            temp += dist
开发者ID:TimothyXie,项目名称:orange3,代码行数:21,代码来源:owsieve.py

示例11: moveTo

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
    def moveTo(self, pos):
        oldX, oldY = self.pos.x(), self.pos.y()
        x,y = pos.x(), pos.y()
        
        #print "BrushingModel.moveTo(pos=%r)" % (pos) 
        line = QGraphicsLineItem(oldX, oldY, x, y)
        line.setPen(QPen( QBrush(Qt.white), self.brushSize, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        self.scene.addItem(line)

        #update bounding Box 
        if not self.bb.isValid():
            self.bb = QRect(QPoint(x,y), QSize(1,1))
        #grow bounding box
        self.bb.setLeft(  min(self.bb.left(),   max(0,                   x-self.brushSize/2-1) ) )
        self.bb.setRight( max(self.bb.right(),  min(self.sliceRect[0]-1, x+self.brushSize/2+1) ) )
        self.bb.setTop(   min(self.bb.top(),    max(0,                   y-self.brushSize/2-1) ) )
        self.bb.setBottom(max(self.bb.bottom(), min(self.sliceRect[1]-1, y+self.brushSize/2+1) ) )
        
        #update/move position
        self.pos = pos
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:22,代码来源:brushingmodel.py

示例12: moveTo

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
    def moveTo(self, pos):    
        lineVis = QGraphicsLineItem(self.pos.x(), self.pos.y(), pos.x(), pos.y())
        lineVis.setPen(self.penVis)
        
        line = QGraphicsLineItem(self.pos.x(), self.pos.y(), pos.x(), pos.y())
        line.setPen(self.penDraw)
        self.scene.addItem(line)

        self.pos = pos
        x = pos.x()
        y = pos.y()
        #update bounding Box :
        if x > self.bb.right():
            self.bb.setRight(x)
        if x < self.bb.left():
            self.bb.setLeft(x)
        if y > self.bb.bottom():
            self.bb.setBottom(y)
        if y < self.bb.top():
            self.bb.setTop(y)
        return lineVis
开发者ID:lcroitor,项目名称:volumeeditor,代码行数:23,代码来源:drawManager.py

示例13: addLink

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
    def addLink(self, output, input):
        """
        Add a link between `output` (:class:`OutputSignal`) and `input`
        (:class:`InputSignal`).

        """
        if not compatible_channels(output, input):
            return

        if output not in self.source.output_channels():
            raise ValueError("%r is not an output channel of %r" % \
                             (output, self.source))

        if input not in self.sink.input_channels():
            raise ValueError("%r is not an input channel of %r" % \
                             (input, self.sink))

        if input.single:
            # Remove existing link if it exists.
            for s1, s2, _ in self.__links:
                if s2 == input:
                    self.removeLink(s1, s2)

        line = QGraphicsLineItem(self)

        source_anchor = self.sourceNodeWidget.anchor(output)
        sink_anchor = self.sinkNodeWidget.anchor(input)

        source_pos = source_anchor.boundingRect().center()
        source_pos = self.mapFromItem(source_anchor, source_pos)

        sink_pos = sink_anchor.boundingRect().center()
        sink_pos = self.mapFromItem(sink_anchor, sink_pos)
        line.setLine(source_pos.x(), source_pos.y(),
                     sink_pos.x(), sink_pos.y())
        pen = QPen(Qt.black, 4)
        pen.setCapStyle(Qt.RoundCap)
        line.setPen(pen)

        self.__links.append(_Link(output, input, line))
开发者ID:Micseb,项目名称:orange3,代码行数:42,代码来源:editlinksdialog.py

示例14: setColor

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
 def setColor(self, color):
     pen = QPen(color)
     QGraphicsLineItem.setPen(self, pen)
开发者ID:karolszczapa,项目名称:GIS,代码行数:5,代码来源:Edge.py

示例15: resetColor

# 需要导入模块: from PyQt4.QtGui import QGraphicsLineItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsLineItem import setPen [as 别名]
 def resetColor(self):
     pen = QPen(QColor.fromRgb(0,0,0))
     QGraphicsLineItem.setPen(self, pen)
开发者ID:karolszczapa,项目名称:GIS,代码行数:5,代码来源:Edge.py


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