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


Python QtWidgets.QGraphicsSimpleTextItem類代碼示例

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


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

示例1: create_time_labels

    def create_time_labels(self):
        """Create the time labels, but don't plot them yet.

        Notes
        -----
        It's necessary to have the height of the time labels, so that we can
        adjust the main scene.

        Not very robust, because it uses seconds as integers.
        """
        min_time = int(floor(min(self.data.axis['time'][0])))
        max_time = int(ceil(max(self.data.axis['time'][0])))
        n_time_labels = self.parent.value('n_time_labels')

        self.idx_time = []
        self.time_pos = []
        for one_time in linspace(min_time, max_time, n_time_labels):
            x_label = (self.data.start_time +
                       timedelta(seconds=one_time)).strftime('%H:%M:%S')
            item = QGraphicsSimpleTextItem(x_label)
            item.setFlag(QGraphicsItem.ItemIgnoresTransformations)
            self.idx_time.append(item)
            self.time_pos.append(QPointF(one_time,
                                         len(self.idx_label) *
                                         self.parent.value('y_distance')))
開發者ID:gpiantoni,項目名稱:phypno,代碼行數:25,代碼來源:traces.py

示例2: __createTexts

 def __createTexts(self):
     """
     Private method to create the text items of the module item.
     """
     if self.model is None:
         return
     
     boldFont = QFont(self.font)
     boldFont.setBold(True)
     
     classes = self.model.getClasses()
     
     x = self.margin + self.rect().x()
     y = self.margin + self.rect().y()
     self.header = QGraphicsSimpleTextItem(self)
     self.header.setFont(boldFont)
     self.header.setText(self.model.getName())
     self.header.setPos(x, y)
     y += self.header.boundingRect().height() + self.margin
     if classes:
         txt = "\n".join(classes)
     else:
         txt = " "
     self.classes = QGraphicsSimpleTextItem(self)
     self.classes.setFont(self.font)
     self.classes.setText(txt)
     self.classes.setPos(x, y)
開發者ID:pycom,項目名稱:EricShort,代碼行數:27,代碼來源:ModuleItem.py

示例3: drawGrid

    def drawGrid(self):
        black_notes = [2,4,6,9,11]
        scale_bar = QGraphicsRectItem(0, 0, self.grid_width, self.note_height, self.piano)
        scale_bar.setPos(self.piano_width, 0)
        scale_bar.setBrush(QColor(100,100,100))
        clearpen = QPen(QColor(0,0,0,0))
        for i in range(self.end_octave - self.start_octave, self.start_octave - self.start_octave, -1):
            for j in range(self.notes_in_octave, 0, -1):
                scale_bar = QGraphicsRectItem(0, 0, self.grid_width, self.note_height, self.piano)
                scale_bar.setPos(self.piano_width, self.note_height * j + self.octave_height * (i - 1))
                scale_bar.setPen(clearpen)
                if j not in black_notes:
                    scale_bar.setBrush(QColor(120,120,120))
                else:
                    scale_bar.setBrush(QColor(100,100,100))

        measure_pen = QPen(QColor(0, 0, 0, 120), 3)
        half_measure_pen = QPen(QColor(0, 0, 0, 40), 2)
        line_pen = QPen(QColor(0, 0, 0, 40))
        for i in range(0, int(self.num_measures) + 1):
            measure = QGraphicsLineItem(0, 0, 0, self.piano_height + self.header_height - measure_pen.width(), self.header)
            measure.setPos(self.measure_width * i, 0.5 * measure_pen.width())
            measure.setPen(measure_pen)
            if i < self.num_measures:
                number = QGraphicsSimpleTextItem('%d' % (i + 1), self.header)
                number.setPos(self.measure_width * i + 5, 2)
                number.setBrush(Qt.white)
                for j in self.frange(0, self.time_sig[0]*self.grid_div/self.time_sig[1], 1.):
                    line = QGraphicsLineItem(0, 0, 0, self.piano_height, self.header)
                    line.setZValue(1.0)
                    line.setPos(self.measure_width * i + self.value_width * j, self.header_height)
                    if j == self.time_sig[0]*self.grid_div/self.time_sig[1] / 2.0:
                        line.setPen(half_measure_pen)
                    else:
                        line.setPen(line_pen)
開發者ID:ViktorNova,項目名稱:Carla,代碼行數:35,代碼來源:pianoroll.py

示例4: _updateLabel

 def _updateLabel(self, isLeft):
     """
     Called by updatePositionAndAppearance during init, or later by
     updateConnectivity. Updates drawing and position of the label.
     """
     lbl = self._label
     if self._idx != None:
         if lbl == None:
             bw = _BASE_WIDTH
             num = self._partner_virtual_helix.number()
             tbr = _FM.tightBoundingRect(str(num))
             half_label_h = tbr.height() / 2.0
             half_label_w = tbr.width() / 2.0
             # determine x and y positions
             labelX = bw / 2.0 - half_label_w
             if self._is_on_top:
                 labelY = -0.25 * half_label_h - 0.5 - 0.5 * bw
             else:
                 labelY = 2 * half_label_h + 0.5 + 0.5 * bw
             # adjust x for left vs right
             labelXoffset = 0.25 * bw if isLeft else -0.25 * bw
             labelX += labelXoffset
             # adjust x for numeral 1
             if num == 1:
                 labelX -= half_label_w / 2.0
             # create text item
             lbl = QGraphicsSimpleTextItem(str(num), self)
             lbl.setPos(labelX, labelY)
             lbl.setBrush(_ENAB_BRUSH)
             lbl.setFont(_toHelixNumFont)
             self._label = lbl
         # end if
         lbl.setText(str(self._partner_virtual_helix.number()))
開發者ID:alyosharomanov,項目名稱:cadnano2.5,代碼行數:33,代碼來源:xoveritem.py

示例5: create_scale

 def create_scale(self):
     section_num = len(self.section_analyzer.section_list)
     section_distance = self.section_analyzer.section_distance
     total_distance = section_num * section_distance
     div = int(Math.integer_division(total_distance, 1.0))
     print(total_distance)
     for i in range(div+1):
         x = self.graph_zero[0] + i * self.length_multiplier + self.line_extend
         y = self.graph_zero[1]
         scale_text = QGraphicsSimpleTextItem("%.2f" % float(i))
         scale_text.setPos(x, y)
         self.addToGroup(scale_text)
     start_to_zero = self.graph_zero[1] - self.position[1]
     step = abs(start_to_zero) // 25
     x = self.graph_zero[0] - 15
     y = self.graph_zero[1]
     for i in range(int(step)-1):
         if i > 0:
             value = i * 25 / 100
             scene_y = y - i * 25
             text = QGraphicsSimpleTextItem("-%.2f" % value)
             text.setPos(x, scene_y)
             self.addToGroup(text)
     start_to_zero = self.position[1] + self.height - self.graph_zero[1]
     step = abs(start_to_zero) // 25
     x = self.graph_zero[0] - 15
     y = self.graph_zero[1]
     for i in range(int(step)-1):
         if i > 0:
             value = i * 25 / 100
             scene_y = y + i * 25
             text = QGraphicsSimpleTextItem("%.2f" % value)
             text.setPos(x, scene_y)
             self.addToGroup(text)
開發者ID:johanesmikhael,項目名稱:ContinuityAnalysis,代碼行數:34,代碼來源:analysis_component.py

示例6: __init__

    def __init__(self):
        super().__init__()

        self.timer = Timer()
        self.timeout_handle = None

        self.qtimer = QTimer()
        self.qtimer.timeout.connect(self.my_update)

        self.label = QGraphicsSimpleTextItem("Stopwatch:", self.root)
        self.time = QGraphicsSimpleTextItem("00:00", self.root)
        self.seconds = QGraphicsSimpleTextItem("00'00", self.root)
開發者ID:Grumbel,項目名稱:clockgr,代碼行數:12,代碼來源:stop_watch.py

示例7: create_chan_labels

    def create_chan_labels(self):
        """Create the channel labels, but don't plot them yet.

        Notes
        -----
        It's necessary to have the width of the labels, so that we can adjust
        the main scene.
        """
        self.idx_label = []
        for one_grp in self.parent.channels.groups:
            for one_label in one_grp['chan_to_plot']:
                item = QGraphicsSimpleTextItem(one_label)
                item.setBrush(QBrush(QColor(one_grp['color'])))
                item.setFlag(QGraphicsItem.ItemIgnoresTransformations)
                self.idx_label.append(item)
開發者ID:gpiantoni,項目名稱:phypno,代碼行數:15,代碼來源:traces.py

示例8: __init__

    def __init__(self, model, manager, text_color=Qt.black):
        bg_color = model.get_bg_color()
        super(BasicNode, self).__init__()
        self.model = model
        text = model.get_display_text()
        self.manager = manager
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setFlag(QGraphicsItem.ItemIsFocusable, True)

        self.text_graph = QGraphicsSimpleTextItem(text)
        self.text_graph.setBrush(text_color)
        bound = self.text_graph.boundingRect()
        r = QPointF(bound.width() / 2, bound.height() / 2)
        text_center = self.text_graph.pos() + r
        self.text_graph.setPos(-text_center)
        self.addToGroup(self.text_graph)

        self.box_graph = BoxOutline(bg_color)
        empty_space = QPointF(UNIT, UNIT)
        newr = (empty_space + r)
        self.box_graph.rect = QRectF(-newr, newr)
        self.addToGroup(self.box_graph)
        self.text_graph.setZValue(1.0)
        self.box_graph.setZValue(0.0)

        self.children = []
開發者ID:spacejump163,項目名稱:ai2,代碼行數:26,代碼來源:tree_edit_view.py

示例9: BasicNode

class BasicNode(QGraphicsItemGroup):
    def __init__(self, model, manager, text_color=Qt.black):
        bg_color = model.get_bg_color()
        super(BasicNode, self).__init__()
        self.model = model
        text = model.get_display_text()
        self.manager = manager
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setFlag(QGraphicsItem.ItemIsFocusable, True)

        self.text_graph = QGraphicsSimpleTextItem(text)
        self.text_graph.setBrush(text_color)
        bound = self.text_graph.boundingRect()
        r = QPointF(bound.width() / 2, bound.height() / 2)
        text_center = self.text_graph.pos() + r
        self.text_graph.setPos(-text_center)
        self.addToGroup(self.text_graph)

        self.box_graph = BoxOutline(bg_color)
        empty_space = QPointF(UNIT, UNIT)
        newr = (empty_space + r)
        self.box_graph.rect = QRectF(-newr, newr)
        self.addToGroup(self.box_graph)
        self.text_graph.setZValue(1.0)
        self.box_graph.setZValue(0.0)

        self.children = []

    def itemChange(self, change, value):
        if change == QGraphicsItem.ItemSelectedChange:
            self.manager.selection_changed(self, value)
            return value
        else:
            return super(BasicNode, self).itemChange(change, value)

    def get_width(self):
        return self.boundingRect().width()

    def set_left_pos(self, pos):
        pos += QPoint(self.get_width() / 2.0, 0)
        self.setPos(pos)

    def left_pos(self):
        return self.pos() - QPointF(self.get_width() / 2.0, 0)

    def center_pos(self):
        return self.pos()

    def right_pos(self):
        return self.pos() + QPointF(self.get_width() / 2.0, 0)

    """
開發者ID:spacejump163,項目名稱:ai2,代碼行數:52,代碼來源:tree_edit_view.py

示例10: WotNode

class WotNode(BaseNode):
    def __init__(self, nx_node, pos):
        """
        Create node in the graph scene

        :param tuple nx_node: Node info
        :param x_y: Position of the node
        """
        super().__init__(nx_node, pos)

        # color around ellipse
        outline_color = QColor('grey')
        outline_style = Qt.SolidLine
        outline_width = 1
        if self.status_wallet:
            outline_color = QColor('black')
            outline_width = 2
        if not self.status_member:
            outline_color = QColor('red')
            outline_style = Qt.SolidLine
        self.setPen(QPen(outline_color, outline_width, outline_style))

        # text inside ellipse
        self.text_item = QGraphicsSimpleTextItem(self)
        self.text_item.setText(self.text)
        text_color = QColor('grey')
        if self.status_wallet == NodeStatus.HIGHLIGHTED:
            text_color = QColor('black')
        self.text_item.setBrush(QBrush(text_color))
        # center ellipse around text
        self.setRect(
            0,
            0,
            self.text_item.boundingRect().width() * 2,
            self.text_item.boundingRect().height() * 2
        )

        #  set anchor to the center
        self.setTransform(
            QTransform().translate(-self.boundingRect().width() / 2.0, -self.boundingRect().height() / 2.0))
        # center text in ellipse
        self.text_item.setPos(self.boundingRect().width() / 4.0, self.boundingRect().height() / 4.0)

        # create gradient inside the ellipse
        gradient = QRadialGradient(QPointF(0, self.boundingRect().height() / 4), self.boundingRect().width())
        gradient.setColorAt(0, QColor('white'))
        gradient.setColorAt(1, QColor('darkgrey'))
        self.setBrush(QBrush(gradient))

        # cursor change on hover
        self.setAcceptHoverEvents(True)
        self.setZValue(1)
開發者ID:duniter,項目名稱:sakia,代碼行數:52,代碼來源:node.py

示例11: __init__

 def __init__(self, *args):
     super(ClearanceWidthGraph, self).__init__(*args)
     self.dimension_analysis = self.section_analyzer.dimension_analysis
     self.clearance_analysis = self.section_analyzer.clearance_analysis
     self.min_horizontal_clearance = self.dimension_analysis.min_horizontal_clearance
     self.graph_zero = [None, None]
     self.graph_end = [None, None]
     self.clearance_label = QGraphicsSimpleTextItem()
     self.addToGroup(self.clearance_label)
     self.clearance_label.setZValue(1.0)
     self.init_dimension()
開發者ID:johanesmikhael,項目名稱:ContinuityAnalysis,代碼行數:11,代碼來源:analysis_component.py

示例12: create_material_legend

 def create_material_legend(self, *args):
     self.position = args[0], args[1]
     square_size = 20
     material_list_key = sorted(self.material_dict)
     x_init = self.position[0] + self.left_margin
     y_init = self.position[1] + self.top_margin
     i = 0
     for key in material_list_key:
         scene_y = y_init + i * (square_size + 5)
         material = self.material_dict[key]
         surface_colour = material.get_surface_colour()
         rect = QGraphicsRectItem(x_init, scene_y, square_size, square_size)
         pen = QPen()
         pen.setWidthF(0.5)
         rect.setPen(pen)
         BaseGraphic.set_rect_fill(self.visualization_mode, rect, surface_colour)
         self.graphic_items.append(rect)
         text = QGraphicsSimpleTextItem(key)
         text.setPos(x_init + square_size + 5, scene_y)
         self.graphic_items.append(text)
         i += 1
開發者ID:johanesmikhael,項目名稱:ContinuityAnalysis,代碼行數:21,代碼來源:analysis_component.py

示例13: createLabel

 def createLabel(self) -> QGraphicsSimpleTextItem:
     """
     Returns:
         the label item
     """
     label = QGraphicsSimpleTextItem("%d" % (self._id_num))
     label.setFont(_FONT)
     label.setZValue(styles.ZPATHHELIX)
     label.setParentItem(self)
     return label
開發者ID:cadnano,項目名稱:cadnano2.5,代碼行數:10,代碼來源:virtualhelixhandleitem.py

示例14: __createTexts

 def __createTexts(self):
     """
     Private method to create the text items of the class item.
     """
     if self.model is None:
         return
     
     boldFont = QFont(self.font)
     boldFont.setBold(True)
     
     attrs = self.model.getAttributes()
     meths = self.model.getMethods()
     
     x = self.margin + self.rect().x()
     y = self.margin + self.rect().y()
     self.header = QGraphicsSimpleTextItem(self)
     self.header.setFont(boldFont)
     self.header.setText(self.model.getName())
     self.header.setPos(x, y)
     y += self.header.boundingRect().height() + self.margin
     if not self.noAttrs and not self.external:
         if attrs:
             txt = "\n".join(attrs)
         else:
             txt = " "
         self.attrs = QGraphicsSimpleTextItem(self)
         self.attrs.setFont(self.font)
         self.attrs.setText(txt)
         self.attrs.setPos(x, y)
         y += self.attrs.boundingRect().height() + self.margin
     else:
         self.attrs = None
     if meths:
         txt = "\n".join(meths)
     else:
         txt = " "
     self.meths = QGraphicsSimpleTextItem(self)
     self.meths.setFont(self.font)
     self.meths.setText(txt)
     self.meths.setPos(x, y)
開發者ID:pycom,項目名稱:EricShort,代碼行數:40,代碼來源:ClassItem.py

示例15: makeCoords

 def makeCoords(self):
     """ draws Coordinates """
     xLabels = "ABCDEFGHIKLMNOPQRSTUVWXYZ"
     yLabels = list(range(1, 26))
     botGrid = []
     leftGrid = []
     # generate pixel coordinates grids
     for n in range(self.board.size):
         (xBot, yBot) = self.grid[self.board.size-1][n]
         yBot += self.baseWidth*0.4/self.baseRectRatio
         xBot -= self.baseWidth*0.1
         botGrid.append((xBot, yBot))
         (xLeft, yLeft) = self.grid[n][0]
         xLeft -= self.baseWidth*1.2
         yLeft -= self.baseWidth*0.3/self.baseRectRatio
         leftGrid.append((xLeft, yLeft))
     # generate Text items and add them to group
     self.coordGroup = QGraphicsItemGroup()
     for n in range(self.board.size):
         leftText = QGraphicsSimpleTextItem(str(yLabels[n]))
         leftText.setPos(*leftGrid[n])
         self.coordGroup.addToGroup(leftText)
         bottomText = QGraphicsSimpleTextItem(xLabels[n])
         bottomText.setPos(*botGrid[n])
         self.coordGroup.addToGroup(bottomText)
     # draw coordinates and update visibility according to self.showCoords
     self.scene.addItem(self.coordGroup)
     self.updateCoords()
開發者ID:drseilzug,項目名稱:GoGote,代碼行數:28,代碼來源:BoardGUI.py


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