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


Python QGraphicsTextItem.paint方法代码示例

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


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

示例1: paint

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsTextItem import paint [as 别名]
 def paint(self, painter, option, widget=None):
     rect = self.rect()
     if self.isSelected():
         option.state ^= QStyle.State_Selected
     font = self.document().defaultFont()
     painter.setFont(font)
     if self.parent:
         draw_text = self.node_inst.description
         if self.parent.x() > self.x():  # node is to the left
             fm = QFontMetrics(font)
             x = rect.width() / 2 - fm.width(draw_text) - 4
         else:
             x = rect.width() / 2 + 4
         painter.drawText(QPointF(x, -self.line_descent - 1), draw_text)
     painter.save()
     painter.setBrush(self.backgroundBrush)
     painter.setPen(QPen(Qt.black, 3 if self.isSelected() else 0))
     adjrect = rect.adjusted(-3, 0, 0, 0)
     if not self.node_inst.children:
         painter.drawRoundedRect(adjrect, 4, 4)
     else:
         painter.drawRect(adjrect)
     painter.restore()
     painter.setClipRect(rect)
     return QGraphicsTextItem.paint(self, painter, option, widget)
开发者ID:RachitKansal,项目名称:orange3,代码行数:27,代码来源:owtreeviewer.py

示例2: paint

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsTextItem import paint [as 别名]
    def paint(self, painter, option, widget=None):
        QGraphicsTextItem.paint(self, painter, option, widget)

        # Draw placeholder text if necessary
        if not (self.toPlainText() and self.toHtml()) and \
                self.__placeholderText and \
                not (self.hasFocus() and \
                     self.textInteractionFlags() & Qt.TextEditable):
            brect = self.boundingRect()
            painter.setFont(self.font())
            metrics = painter.fontMetrics()
            text = metrics.elidedText(self.__placeholderText, Qt.ElideRight,
                                      brect.width())
            color = self.defaultTextColor()
            color.setAlpha(min(color.alpha(), 150))
            painter.setPen(QPen(color))
            painter.drawText(brect, Qt.AlignTop | Qt.AlignLeft, text)
开发者ID:PrimozGodec,项目名称:orange3,代码行数:19,代码来源:annotationitem.py

示例3: paint

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsTextItem import paint [as 别名]
 def paint(self, painter, option, widget=0):
     painter.save()
     painter.setBrush(self.backgroundBrush)
     painter.setPen(QPen(Qt.gray))
     rect = self.rect()
     painter.drawRoundedRect(rect, 4, 4)
     painter.restore()
     painter.setClipRect(rect)
     return QGraphicsTextItem.paint(self, painter, option, widget)
开发者ID:janezd,项目名称:orange3,代码行数:11,代码来源:owtreeviewer2d.py


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