python类ElideRight()的实例源码

qteditorfactory.py 文件源码 项目:QtPropertyBrowserV2.6-for-pyqt5 作者: theall 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def createEditor(self, manager, property, parent):
        editor = self.d_ptr.createEditor(property, parent)
        editor.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
        editor.setMinimumContentsLength(1)
        editor.view().setTextElideMode(Qt.ElideRight)
        enumNames = manager.enumNames(property)
        editor.addItems(enumNames)
        enumIcons = manager.enumIcons(property)
        enumNamesCount = len(enumNames)
        for i in range(enumNamesCount):
            icon = enumIcons[i]
            if type(icon) is not QIcon:
                icon = QIcon()
            editor.setItemIcon(i, icon)
        editor.setCurrentIndex(manager.value(property))

        editor.currentIndexChanged.connect(self.d_ptr.slotSetValue)
        editor.destroyed.connect(self.d_ptr.slotEditorDestroyed)
        return editor

    ###
    #   \internal

    #   Reimplemented from the QtAbstractEditorFactory class.
    ###
GeneratorTabController.py 文件源码 项目:urh 作者: jopohl 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def on_table_selection_changed(self):
        min_row, max_row, start, end = self.ui.tableMessages.selection_range()

        if min_row == -1:
            self.ui.lEncodingValue.setText("-")  #
            self.ui.lEncodingValue.setToolTip("")
            self.label_list_model.message = None
            return

        container = self.table_model.protocol
        message = container.messages[min_row]
        self.label_list_model.message = message
        decoder_name = message.decoder.name
        metrics = QFontMetrics(self.ui.lEncodingValue.font())
        elidedName = metrics.elidedText(decoder_name, Qt.ElideRight, self.ui.lEncodingValue.width())
        self.ui.lEncodingValue.setText(elidedName)
        self.ui.lEncodingValue.setToolTip(decoder_name)
        self.ui.cBoxModulations.blockSignals(True)
        self.ui.cBoxModulations.setCurrentIndex(message.modulator_index)
        self.show_modulation_info()
        self.ui.cBoxModulations.blockSignals(False)
videolist.py 文件源码 项目:vidcutter 作者: ozmartian 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def clipText(self, text: str, painter: QPainter) -> str:
        metrics = painter.fontMetrics()
        return metrics.elidedText(text, Qt.ElideRight, (self.parent.width() - 100 - 10))
BiocImageBuilderMain.py 文件源码 项目:BiocImageBuilder 作者: Bioconductor-notebooks 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _set_building_text(self, labelCtrl, text):
        metrics = QtGui.QFontMetrics(labelCtrl.font())
        elidedText = metrics.elidedText(text, Qt.ElideRight, labelCtrl.width())
        labelCtrl.setText(elidedText)
glyphCellFactory.py 文件源码 项目:defconQt 作者: trufont 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def drawCellHeaderText(self, painter, rect):
        xMin, yMin, width, height = rect
        metrics = QFontMetrics(headerFont)
        minOffset = painter.pen().width()

        painter.setFont(headerFont)
        painter.setPen(cellMetricsTextColor)
        name = metrics.elidedText(
            self.glyph.name, Qt.ElideRight, width - 2)
        painter.drawText(
            1, 0, width - 2, height - minOffset,
            Qt.TextSingleLine | Qt.AlignCenter | Qt.AlignBottom, name)


问题


面经


文章

微信
公众号

扫码关注公众号