• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python QtGui.QFontMetricsF类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qgis.PyQt.QtGui.QFontMetricsF的典型用法代码示例。如果您正苦于以下问题:Python QFontMetricsF类的具体用法?Python QFontMetricsF怎么用?Python QFontMetricsF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getLinkPointForOutput

 def getLinkPointForOutput(self, outputIndex):
     if isinstance(self.element, QgsProcessingModelChildAlgorithm) and self.element.algorithm().outputDefinitions():
         outputIndex = (outputIndex if not self.element.outputsCollapsed() else -1)
         text = self.getAdjustedText(self.element.algorithm().outputDefinitions()[outputIndex].description())
         font = QFont('Verdana', 8)
         font.setPixelSize(12)
         fm = QFontMetricsF(font)
         w = fm.width(text)
         h = fm.height() * 1.2 * (outputIndex + 1) + fm.height() / 2.0
         y = h + ModelerGraphicItem.BOX_HEIGHT / 2.0 + 5
         x = (-ModelerGraphicItem.BOX_WIDTH / 2 + 33 + w + 5
              if not self.element.outputsCollapsed()
              else 10)
         return QPointF(x, y)
     else:
         return QPointF(0, 0)
开发者ID:blazek,项目名称:QGIS,代码行数:16,代码来源:ModelerGraphicItem.py


示例2: boundingRect

    def boundingRect(self):
        font = QFont('Verdana', 8)
        font.setPixelSize(12)
        fm = QFontMetricsF(font)
        unfolded = isinstance(self.element, QgsProcessingModelChildAlgorithm) and not self.element.parametersCollapsed()
        numParams = len([a for a in self.element.algorithm().parameterDefinitions() if not a.isDestination()]) if unfolded else 0
        unfolded = isinstance(self.element, QgsProcessingModelChildAlgorithm) and not self.element.outputsCollapsed()
        numOutputs = len(self.element.algorithm().outputDefinitions()) if unfolded else 0

        hUp = fm.height() * 1.2 * (numParams + 2)
        hDown = fm.height() * 1.2 * (numOutputs + 2)
        rect = QRectF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2,
                      -(ModelerGraphicItem.BOX_HEIGHT + 2) / 2 - hUp,
                      ModelerGraphicItem.BOX_WIDTH + 2,
                      ModelerGraphicItem.BOX_HEIGHT + hDown + hUp)
        return rect
开发者ID:blazek,项目名称:QGIS,代码行数:16,代码来源:ModelerGraphicItem.py


示例3: getLinkPointForParameter

 def getLinkPointForParameter(self, paramIndex):
     offsetX = 25
     if isinstance(self.element, QgsProcessingModelChildAlgorithm) and self.element.parametersCollapsed():
         paramIndex = -1
         offsetX = 17
     if isinstance(self.element, QgsProcessingModelParameter):
         paramIndex = -1
         offsetX = 0
     font = QFont('Verdana', 8)
     font.setPixelSize(12)
     fm = QFontMetricsF(font)
     if isinstance(self.element, QgsProcessingModelChildAlgorithm):
         h = -(fm.height() * 1.2) * (paramIndex + 2) - fm.height() / 2.0 + 8
         h = h - ModelerGraphicItem.BOX_HEIGHT / 2.0
     else:
         h = 0
     return QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + offsetX, h)
开发者ID:blazek,项目名称:QGIS,代码行数:17,代码来源:ModelerGraphicItem.py


示例4: paint

    def paint(self, painter, option, widget=None):
        rect = QRectF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2.0,
                      -(ModelerGraphicItem.BOX_HEIGHT + 2) / 2.0,
                      ModelerGraphicItem.BOX_WIDTH + 2,
                      ModelerGraphicItem.BOX_HEIGHT + 2)

        if isinstance(self.element, QgsProcessingModelParameter):
            color = QColor(238, 242, 131)
            stroke = QColor(234, 226, 118)
            selected = QColor(116, 113, 68)
        elif isinstance(self.element, QgsProcessingModelChildAlgorithm):
            color = QColor(255, 255, 255)
            stroke = Qt.gray
            selected = QColor(50, 50, 50)
        else:
            color = QColor(172, 196, 114)
            stroke = QColor(90, 140, 90)
            selected = QColor(42, 65, 42)
        if self.isSelected():
            stroke = selected
            color = color.darker(110)
        painter.setPen(QPen(stroke, 0))  # 0 width "cosmetic" pen
        painter.setBrush(QBrush(color, Qt.SolidPattern))
        painter.drawRect(rect)
        font = QFont('Verdana', 8)
        font.setPixelSize(12)
        painter.setFont(font)
        painter.setPen(QPen(Qt.black))
        text = self.getAdjustedText(self.text)
        if isinstance(self.element, QgsProcessingModelChildAlgorithm) and not self.element.isActive():
            painter.setPen(QPen(Qt.gray))
            text = text + "\n(deactivated)"
        fm = QFontMetricsF(font)
        text = self.getAdjustedText(self.text)
        h = fm.ascent()
        pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, ModelerGraphicItem.BOX_HEIGHT / 2.0 - h + 1)
        painter.drawText(pt, text)
        painter.setPen(QPen(Qt.black))
        if isinstance(self.element, QgsProcessingModelChildAlgorithm):
            h = -(fm.height() * 1.2)
            h = h - ModelerGraphicItem.BOX_HEIGHT / 2.0 + 5
            pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h)
            painter.drawText(pt, 'In')
            i = 1
            if not self.element.parametersCollapsed():
                for param in [p for p in self.element.algorithm().parameterDefinitions() if not p.isDestination()]:
                    if not param.flags() & QgsProcessingParameterDefinition.FlagHidden:
                        text = self.getAdjustedText(param.description())
                        h = -(fm.height() * 1.2) * (i + 1)
                        h = h - ModelerGraphicItem.BOX_HEIGHT / 2.0 + 5
                        pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 33, h)
                        painter.drawText(pt, text)
                        i += 1
            h = fm.height() * 1.1
            h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
            pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h)
            painter.drawText(pt, 'Out')
            if not self.element.outputsCollapsed():
                for i, out in enumerate(self.element.algorithm().outputDefinitions()):
                    text = self.getAdjustedText(out.description())
                    h = fm.height() * 1.2 * (i + 2)
                    h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
                    pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 33, h)
                    painter.drawText(pt, text)
        if self.pixmap:
            painter.drawPixmap(-(ModelerGraphicItem.BOX_WIDTH / 2.0) + 3, -8,
                               self.pixmap)
        elif self.picture:
            painter.drawPicture(-(ModelerGraphicItem.BOX_WIDTH / 2.0) + 3, -8,
                                self.picture)
开发者ID:blazek,项目名称:QGIS,代码行数:70,代码来源:ModelerGraphicItem.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python QtGui.QGradient类代码示例发布时间:2022-05-26
下一篇:
Python QtGui.QFontDatabase类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap