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


Python QFontMetricsF.height方法代码示例

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


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

示例1: paint

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
 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)
     painter.setPen(QPen(Qt.gray, 1))
     color = QColor(125, 232, 232)
     if isinstance(self.element, ModelerParameter):
         color = QColor(179, 179, 255)
     elif isinstance(self.element, Algorithm):
         color = Qt.white
     painter.setBrush(QBrush(color, Qt.SolidPattern))
     painter.drawRect(rect)
     font = QFont('Verdana', 8)
     painter.setFont(font)
     painter.setPen(QPen(Qt.black))
     text = self.getAdjustedText(self.text)
     if isinstance(self.element, Algorithm) and not self.element.active:
         painter.setPen(QPen(Qt.gray))
         text = text + "\n(deactivated)"
     elif self.isSelected():
         painter.setPen(QPen(Qt.blue))
     fm = QFontMetricsF(font)
     text = self.getAdjustedText(self.text)
     h = fm.height()
     pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h / 2.0)
     painter.drawText(pt, text)
     painter.setPen(QPen(Qt.black))
     if isinstance(self.element, Algorithm):
         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.paramsFolded:
             for param in self.element.algorithm.parameters:
                 if not param.hidden:
                     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.2
         h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
         pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h)
         painter.drawText(pt, 'Out')
         if not self.element.outputsFolded:
             for i, out in enumerate(self.element.algorithm.outputs):
                 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)
开发者ID:ar-jan,项目名称:QGIS,代码行数:61,代码来源:ModelerGraphicItem.py

示例2: getLinkPointForParameter

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
 def getLinkPointForParameter(self, paramIndex):
     offsetX = 25
     if isinstance(self.element, Algorithm) and self.element.paramsFolded:
         paramIndex = -1
         offsetX = 17
     font = QFont('Verdana', 8)
     fm = QFontMetricsF(font)
     if isinstance(self.element, Algorithm):
         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:ar-jan,项目名称:QGIS,代码行数:15,代码来源:ModelerGraphicItem.py

示例3: getLinkPointForOutput

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
 def getLinkPointForOutput(self, outputIndex):
     if isinstance(self.element, Algorithm):
         outputIndex = outputIndex if not self.element.outputsFolded else -1
         text = self.getAdjustedText(self.element.algorithm.outputs[outputIndex].description)
         font = QFont("Verdana", 8)
         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.outputsFolded else 10
         return QPointF(x, y)
     else:
         return QPointF(0, 0)
开发者ID:olivierdalang,项目名称:QGIS,代码行数:15,代码来源:ModelerGraphicItem.py

示例4: boundingRect

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
    def boundingRect(self):
        font = QFont('Verdana', 8)
        fm = QFontMetricsF(font)
        unfolded = isinstance(self.element, Algorithm) and not self.element.paramsFolded
        numParams = len(self.element.algorithm.parameters) if unfolded else 0
        unfolded = isinstance(self.element, Algorithm) and not self.element.outputsFolded
        numOutputs = len(self.element.algorithm.outputs) 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:ar-jan,项目名称:QGIS,代码行数:17,代码来源:ModelerGraphicItem.py

示例5: polygon

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
 def polygon(self):
     font = QFont("Verdana", 8)
     fm = QFontMetricsF(font)
     hUp = fm.height() * 1.2 * (len(self.element.parameters) + 2)
     hDown = fm.height() * 1.2 * (len(self.element.outputs) + 2)
     pol = QPolygonF(
         [
             QPointF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2, -(ModelerGraphicItem.BOX_HEIGHT + 2) / 2 - hUp),
             QPointF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2, (ModelerGraphicItem.BOX_HEIGHT + 2) / 2 + hDown),
             QPointF((ModelerGraphicItem.BOX_WIDTH + 2) / 2, (ModelerGraphicItem.BOX_HEIGHT + 2) / 2 + hDown),
             QPointF((ModelerGraphicItem.BOX_WIDTH + 2) / 2, -(ModelerGraphicItem.BOX_HEIGHT + 2) / 2 - hUp),
             QPointF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2, -(ModelerGraphicItem.BOX_HEIGHT + 2) / 2 - hUp),
         ]
     )
     return pol
开发者ID:olivierdalang,项目名称:QGIS,代码行数:17,代码来源:ModelerGraphicItem.py

示例6: plot

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
    def plot(self, under, over):
    
        if not under:
            return
        
        ctx = PaintGL.instance().currentContext
        painter = ctx.painter
        plotm = PlotModule.instance()
        plot_width, plot_height = plotm.getPlotWindow()
        
        metrics = QFontMetricsF(QFont())

        painter.save()
        painter.setPen(QColor(0, 0, 160))
        painter.setBrush(QColor(255, 255, 255, 192))
        painter.setCompositionMode(painter.CompositionMode_SourceOver)

        for point, label in self.locations:
            ok, x, y = plotm.GeoToPhys(point.x(), point.y())
            y = plot_height - y
            if ok:
                rect = QRectF(x, y, metrics.width(label) + 8, metrics.height() + 8)
                painter.drawRect(rect)
                painter.drawText(rect, Qt.AlignCenter, label)

        painter.restore()
开发者ID:metno,项目名称:python-diana,代码行数:28,代码来源:manager.py

示例7: minimumSizeHint

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
 def minimumSizeHint(self):
     font = QFont(self.font())
     font.setPointSize(font.pointSize() - 1)
     fm = QFontMetricsF(font)
     return QSize(fm.width(FractionSlider.WSTRING) *
                  self.__denominator,
                  (fm.height() * 4) + FractionSlider.YMARGIN)
开发者ID:imagingearth,项目名称:PyQt4-Examples,代码行数:9,代码来源:fractionslider.py

示例8: minimumSizeHint

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
	def minimumSizeHint(self):
		"Pour être sûr que le texte du chrono ne soit pas tronqué"
		font = QFont(self.font())
		font.setPointSize(font.pointSize() - 1)
		fm = QFontMetricsF(font)
		l = fm.width(TracerChrono.TAILLE*2) # + 10.
		L = fm.height() + 2.
		return QSize(l, L)
开发者ID:Ptaah,项目名称:Ekd,代码行数:10,代码来源:mplayer.py

示例9: resizeEvent

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
 def resizeEvent(self, event=None):
     fm = QFontMetricsF(self.font())
     x = (self.width() - self.label.width()) / 2
     y = self.height() - (fm.height() * 1.5)
     self.label.move(x, y)
     y = self.height() / 60.0
     x = (self.width() / 4.0) - self.leftSpinBox.width()
     self.leftSpinBox.move(x, y)
     x = self.width() - (self.width() / 4.0)
     self.rightSpinBox.move(x, y)
开发者ID:dpeinado,项目名称:restec,代码行数:12,代码来源:ypipewidget.py

示例10: paintEvent

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
 def paintEvent(self, event=None):
     font = QFont(self.font())
     font.setPointSize(font.pointSize() - 1)
     fm = QFontMetricsF(font)
     fracWidth = fm.width(FractionSlider.WSTRING)
     indent = fm.boundingRect("9").width() / 2.0
     if not X11:
         fracWidth *= 1.5
     span = self.width() - (FractionSlider.XMARGIN * 2)
     value = self.__numerator / float(self.__denominator)
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.setRenderHint(QPainter.TextAntialiasing)
     painter.setPen(self.palette().color(QPalette.Mid))
     painter.setBrush(self.palette().brush(
             QPalette.AlternateBase))
     painter.drawRect(self.rect())
     segColor = QColor(Qt.green).dark(120)
     segLineColor = segColor.dark()
     painter.setPen(segLineColor)
     painter.setBrush(segColor)
     painter.drawRect(FractionSlider.XMARGIN,
                      FractionSlider.YMARGIN, span, fm.height())
     textColor = self.palette().color(QPalette.Text)
     segWidth = span / self.__denominator
     segHeight = fm.height() * 2
     nRect = fm.boundingRect(FractionSlider.WSTRING)
     x = FractionSlider.XMARGIN
     yOffset = segHeight + fm.height()
     for i in range(self.__denominator + 1):
         painter.setPen(segLineColor)
         painter.drawLine(x, FractionSlider.YMARGIN, x, segHeight)
         painter.setPen(textColor)
         y = segHeight
         rect = QRectF(nRect)
         rect.moveCenter(QPointF(x, y + fm.height() / 2.0))
         painter.drawText(rect, Qt.AlignCenter,
                          QString.number(i))
         y = yOffset
         rect.moveCenter(QPointF(x, y + fm.height() / 2.0))
         painter.drawText(rect, Qt.AlignCenter,
                          QString.number(self.__denominator))
         painter.drawLine(QPointF(rect.left() + indent, y),
                          QPointF(rect.right() - indent, y))
         x += segWidth
     span = int(span)
     y = FractionSlider.YMARGIN - 0.5
     triangle = [QPointF(value * span, y),
                 QPointF((value * span) +
                         (2 * FractionSlider.XMARGIN), y),
                 QPointF((value * span) +
                         FractionSlider.XMARGIN, fm.height())]
     painter.setPen(Qt.yellow)
     painter.setBrush(Qt.darkYellow)
     painter.drawPolygon(QPolygonF(triangle))
开发者ID:imagingearth,项目名称:PyQt4-Examples,代码行数:57,代码来源:fractionslider.py

示例11: paintEvent

# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import height [as 别名]
	def paintEvent(self, event = None):
		
		LogicalSize = 100.0

		def logicalFromPhysical(length, side):
			return (length / side) * LogicalSize

		fm = QFontMetricsF(self.font())
		ymargin = ((LogicalSize / 30.0) + logicalFromPhysical(self.leftSpinBox.height(), self.height()))
		ymax = (LogicalSize - logicalFromPhysical(fm.height() * 2, self.height()))
		width = LogicalSize / 4.0
		
		cx, cy = LogicalSize / 2.0, LogicalSize / 3.0
		ax, ay = cx - (2 * width), ymargin
		bx, by = cx - width, ay
		dx, dy = cx + width, ay
		ex, ey = cx + (2 * width), ymargin
		fx, fy = cx + (width / 2), cx + (LogicalSize / 24.0)
		gx, gy = fx, ymax
		hx, hy = cx - (width / 2), ymax
		ix, iy = hx, fy

		painter = QPainter(self)
		painter.setRenderHint(QPainter.Antialiasing)
		side = min(self.width(), self.height())
		painter.setViewport((self.width() - side) / 2, (self.height() - side) / 2, side, side)
		painter.setWindow(0, 0, LogicalSize, LogicalSize)

		painter.setPen(Qt.NoPen)

		gradient = QLinearGradient(QPointF(0, 0), QPointF(0, 100))
		gradient.setColorAt(0, Qt.white)
		a = self.leftSpinBox.value()
		gradient.setColorAt(1, (Qt.red if a != 0 else Qt.white))
		painter.setBrush(QBrush(gradient))
		painter.drawPolygon(QPolygon([ax, ay, bx, by, cx, cy, ix, iy]))

		gradient = QLinearGradient(QPointF(0, 0), QPointF(0, 100))
		gradient.setColorAt(0, Qt.white)
		b = self.rightSpinBox.value()
		gradient.setColorAt(1, (Qt.blue if b != 0 else Qt.white))
		painter.setBrush(QBrush(gradient))
		painter.drawPolygon(QPolygon([cx, cy, dx, dy, ex, ey, fx, fy]))

		if (a + b) == 0:
			color = QColor(Qt.white)
		else:
			ashare = (a / (a + b)) * 255.0
			bshare = 255.0 - ashare
			color = QColor(ashare, 0, bshare)

		gradient = QLinearGradient(QPointF(0, 0), QPointF(0, 100))
		gradient.setColorAt(0, Qt.white)
		gradient.setColorAt(1, color)
		painter.setBrush(QBrush(gradient))
		painter.drawPolygon(QPolygon([cx, cy, fx, fy, gx, gy, hx, hy, ix, iy]))

		painter.setPen(Qt.black)
		painter.drawPolyline(QPolygon([ax, ay, ix, iy, hx, hy]))
		painter.drawPolyline(QPolygon([gx, gy, fx, fy, ex, ey]))
		painter.drawPolyline(QPolygon([bx, by, cx, cy, dx, dy]))
开发者ID:vamtiger-project,项目名称:python-desktop-gui-practice,代码行数:63,代码来源:23-ypipewidget_practice.py


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