當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QGraphicsSimpleTextItem類代碼示例

本文整理匯總了Python中PyQt4.QtGui.QGraphicsSimpleTextItem的典型用法代碼示例。如果您正苦於以下問題:Python QGraphicsSimpleTextItem類的具體用法?Python QGraphicsSimpleTextItem怎麽用?Python QGraphicsSimpleTextItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QGraphicsSimpleTextItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update_items

    def update_items(self):
        self.item = QGraphicsRectItem(
            0, 0, self.width, self.row_h * self.coeff_h)
        seq_width = 0
        nopen = QPen(Qt.NoPen)
        self.item.setPen(nopen)
        font = QFont(self.ftype, self.fsize)
        if self.fstyle == "italic":
            font.setStyle(QFont.StyleItalic)
        elif self.fstyle == "oblique":
            font.setStyle(QFont.StyleOblique)
        rect_cls = QGraphicsRectItem
        for i, val in enumerate(self.liste):
            width = self.col_w
            height = self.row_h * len(str(val)) + 1
            rectitem = rect_cls(0, 0, width, height, parent=self.item)
            rectitem.setX(seq_width)  # to give correct X to children item
            rectitem.setBrush(QBrush(QColor(self.bgcolor)))
            rectitem.setPen(nopen)

            # write letter if enough space in height
            if height >= self.fsize:
                text = QGraphicsSimpleTextItem(str(val), parent=rectitem)
                text.setFont(font)
                text.setBrush(QBrush(QColor(self.fgcolor)))
                # Center text according to rectitem size
                # txtw = text.boundingRect().width()
                txth = text.boundingRect().height()
                text.setRotation(self.rot)
                text.setX(txth)
            seq_width += width
        self.width = seq_width
開發者ID:UdeM-LBIT,項目名稱:CoreTracker,代碼行數:32,代碼來源:Faces.py

示例2: draw_x_axis

    def draw_x_axis(self):
        #lineItem = QGraphicsLineItem(self.col_w/2,
        #                                   self.coordY(self.ylim[0])+2,
        #                                   self.width-self.col_w/2,
        #                                   self.coordY(self.ylim[0])+2,
        #                                   parent=self.item)
        #lineItem.setPen(QPen(QColor('black')))
        #lineItem.setZValue(10)
        #all_vals = list(range(0, len(self.values), 5))
        #if (len(self.values)-1)%5:
        #    all_vals += [len(self.values)-1]
        for x, lab in enumerate(self.values):
#            lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0])+2,
#                                               0, self.coordY(self.ylim[0])+6,
#                                               parent=self.item)
#            lineItem.setX(x*self.col_w + self.col_w/2)
#            lineItem.setPen(QPen(QColor('black')))
#            lineItem.setZValue(10)
            text = QGraphicsSimpleTextItem(str(lab))
            text.rotate(-90)
            text.setFont(QFont("Arial", self.fsize-2))
            text.setParentItem(self.item)
            tw = text.boundingRect().height()
            # Center text according to masterItem size
            text.setPos(x*self.col_w-tw/2 + self.col_w/2,
                        self.coordY(self.ylim[0]))
開發者ID:meren,項目名稱:ebov,代碼行數:26,代碼來源:rulerface.py

示例3: __init__

 def __init__(self, longitude, latitude, text, scene, parent=None, min_zoom_visibility=None):
     pos = scene.posFromLonLat(longitude, latitude)
     QGraphicsSimpleTextItem.__init__(self, text, scene=scene, parent=parent)
     self._min_zoom = min_zoom_visibility
     self._lon, self._lat = longitude, latitude
     self.setPos(pos)
     self.updatePosition(scene)
開發者ID:rugolotti,項目名稱:PyTileMap,代碼行數:7,代碼來源:mapitems.py

示例4: __init__

 def __init__(self, face, node, text):
     QGraphicsSimpleTextItem.__init__(self, text)
     _ActionDelegator.__init__(self)
     self.node = node
     self.face = face
     self._bounding_rect = self.face.get_bounding_rect()
     self._real_rect = self.face.get_real_rect()
開發者ID:sshukla31,項目名稱:misc_algos,代碼行數:7,代碼來源:qt4_face_render.py

示例5: paint

    def paint( self, painter, option, widget ):
        color = self.__settings.lineColor
        if self.color:
            color = self.color

        self.setBrush( QBrush( color ) )
        QGraphicsSimpleTextItem.paint( self, painter, option, widget )
        return
開發者ID:fukanchik,項目名稱:codimension,代碼行數:8,代碼來源:auxitems.py

示例6: __init__

    def __init__( self, settings, text ):
        QGraphicsSimpleTextItem.__init__( self )
        self.__settings = settings

        self.setFont( settings.badgeFont )
        self.setText( text )

        self.color = None
        return
開發者ID:fukanchik,項目名稱:codimension,代碼行數:9,代碼來源:auxitems.py

示例7: update_items

 def update_items(self):
     #self.item = QGraphicsRectItem(0,0,self._total_w, self.row_h)
     seq_width = 0
     nopen = QPen(QtCore.Qt.NoPen)
     font = QFont("Courier", self.fsize)
     rect_cls = self.InteractiveLetterItem if self.interact else QGraphicsRectItem
     for i, letter in enumerate(self.seq):
         width = self.col_w
         for m in self.special_col:
             if m[0] < i <= m[1]:
                 width = self.alt_col_w
                 break
         #load interactive item if called correspondingly
         rectItem = rect_cls(0, 0, width, self.row_h, parent=self.item)
         rectItem.setX(seq_width) # to give correct X to children item
         rectItem.setBrush(self.bg_col[letter])
         rectItem.setPen(nopen)
         if self.interact:
             if self.codon:
                 rectItem.codon = '%s, %d: %s' % (self.seq[i], i,
                                                  self.codon[i*3:i*3+3])
             else:
                 rectItem.codon = '%s, %d' % (self.seq[i], i)
         # write letter if enough space
         if width >= self.fsize:
             text = QGraphicsSimpleTextItem(letter, parent=rectItem)
             text.setFont(font)
             text.setBrush(self.fg_col[letter])
             # Center text according to rectItem size
             tw = text.boundingRect().width()
             th = text.boundingRect().height()
             text.setPos((width - tw)/2, (self.row_h - th)/2)
         seq_width += width
     self.width = seq_width
開發者ID:alxndrsPittis,項目名稱:ete,代碼行數:34,代碼來源:test_new_sequence_face.py

示例8: __init__

    def __init__(self, table, vector, mass=1.0):
        """Documentation here"""

        self.name = table.name
        self._mediator = Mediator()

        # layout widget
        x, y = vector.x, vector.y
        text = QGraphicsSimpleTextItem('{0} as {1}'.format(self.name, self.alias))
        width = text.boundingRect().width()
        QGraphicsRectItem.__init__(self, x, y, width + 10, 22)

        self.table = table.alias(self.alias)

        self.setBrush(Qt.cyan)
        self.setPen(Qt.darkCyan)

        self.width = width + 10
        self.height = 22
        self.setFlag(self.ItemIsSelectable, True)

        text.setParentItem(self)
        text.setX(x + 5)
        text.setY(y + 5)

        self.point = vector
        self.mass = mass
        self.velocity = Vector(0, 0)
        self.force = Vector(0, 0)
        self.instances.append(self)
開發者ID:richardmurri,項目名稱:Query-Browser,代碼行數:30,代碼來源:scene.py

示例9: set_labels

    def set_labels(self, labels):
        """Set the text labels."""
        self.clear()
        orientation = Qt.Horizontal if self.orientation == Qt.Vertical else Qt.Vertical
        for text in labels:
            item = QGraphicsSimpleTextItem(text, self)
            item.setFont(self.font())
            item.setToolTip(text)
            witem = WrapperLayoutItem(item, orientation, parent=self)
            self.layout().addItem(witem)
            self.layout().setAlignment(witem, self.alignment)
            self.label_items.append(item)

        self.layout().activate()
        self.updateGeometry()
開發者ID:jujuefengliu,項目名稱:orange3,代碼行數:15,代碼來源:owhierarchicalclustering.py

示例10: showMoveHelper

 def showMoveHelper(self, visible=True):
     """show help text In empty HandBoards"""
     if visible:
         if not self.__moveHelper:
             splitter = QGraphicsRectItem(self)
             hbCenter = self.rect().center()
             splitter.setRect(hbCenter.x() * 0.5, hbCenter.y(), hbCenter.x() * 1, 1)
             helpItems = [splitter]
             for name, yFactor in [(m18n('Move Exposed Tiles Here'), 0.5),
                                     (m18n('Move Concealed Tiles Here'), 1.5)]:
                 helper = QGraphicsSimpleTextItem(name, self)
                 helper.setScale(3)
                 nameRect = QRectF()
                 nameRect.setSize(helper.mapToParent(helper.boundingRect()).boundingRect().size())
                 center = QPointF(hbCenter)
                 center.setY(center.y() * yFactor)
                 helper.setPos(center - nameRect.center())
                 if self.sceneRotation() == 180:
                     rotateCenter(helper, 180)
                 helpItems.append(helper)
             self.__moveHelper = self.scene().createItemGroup(helpItems)
         self.__moveHelper.setVisible(True)
     else:
         if self.__moveHelper:
             self.__moveHelper.setVisible(False)
開發者ID:ospalh,項目名稱:kajongg-fork,代碼行數:25,代碼來源:handboard.py

示例11: setPageHead

 def setPageHead(self, len):
     count = 0
     x = 95
     while count < len:
         item = QGraphicsSimpleTextItem()
         item.setFont(self.font)
         item.setText("%.2x" % count)
         item.setPos(x, 3)
         self.scene.addItem(item)
         x += self.pagew + 2
         count += 1
開發者ID:udgover,項目名稱:modules,代碼行數:11,代碼來源:pageView.py

示例12: setNumber

 def setNumber(self):
     """docstring for setNumber"""
     if self.label == None:
         self.label = QGraphicsSimpleTextItem("%d" % self._number)
         self.label.setFont(self.font)
         self.label.setParentItem(self)
     y_val = self.radius / 3
     if self._number < 10:
         self.label.setPos(self.radius / 1.5, y_val)
     elif self._number < 100:
         self.label.setPos(self.radius / 3, y_val)
     else: # _number >= 100
         self.label.setPos(0, y_val)
開發者ID:REC17,項目名稱:cadnano2,代碼行數:13,代碼來源:pathhelixhandle.py

示例13: __init__

 def __init__(self, pathHelixGroup):
     super(ActiveSliceHandle, self).__init__(pathHelixGroup)
     self._pathHelixGroup = None
     self._activeSlice = 0
     self._dragMode = False
     self._label = QGraphicsSimpleTextItem("", parent=self)
     self._label.setPos(0, -18)
     self._label.setFont(self._myfont)
     self._label.setBrush(self._labelbrush)
     self._label.hide()
     self.setPathHelixGroup(pathHelixGroup)
     self.setFlag(QGraphicsItem.ItemIsMovable)
     self.setAcceptHoverEvents(True)
     self.setZValue(styles.ZACTIVESLICEHANDLE)
開發者ID:REC17,項目名稱:cadnano2,代碼行數:14,代碼來源:activeslicehandle.py

示例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
開發者ID:xguse,項目名稱:ete,代碼行數:42,代碼來源:item_faces.py

示例15: __init__

 def __init__(self, parentPH, fromStrand, fromIdx, toVH, toIdx, orientedLeft):
     super(PreCrossoverHandle, self).__init__(parentPH)
     self.fromVH = parentPH.vhelix()
     self.fromStrand = fromStrand
     self.fromIdx = fromIdx
     self.toVH = toVH
     self.toIdx = toIdx
     self.orientedLeft = orientedLeft
     
     self.fromVH.basesModified.connect(self.updateVisibilityAndEnabledness)
     self.toVH.basesModified.connect(self.updateVisibilityAndEnabledness)
     
     self.label = QGraphicsSimpleTextItem(str(toVH.number()), parent=self)
     self.label.setFont(self.toHelixNumFont)
     
     x = self.baseWidth * self.fromIdx
     y = (-1.25 if self.onTopStrand() else 2.25) * self.baseWidth
     self.setPos(x, y)
     halfLabelW = self.label.boundingRect().width() / 2
     labelX = self.baseWidth/2 - halfLabelW
     labelY = (-.10 if self.onTopStrand() else .48) * self.baseWidth
     self.label.setPos(labelX, labelY)
     self.updateVisibilityAndEnabledness()
開發者ID:REC17,項目名稱:cadnano2,代碼行數:23,代碼來源:precrossoverhandle.py


注:本文中的PyQt4.QtGui.QGraphicsSimpleTextItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。