本文整理汇总了Python中PyQt5.QtCore.Qt.ElideRight方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.ElideRight方法的具体用法?Python Qt.ElideRight怎么用?Python Qt.ElideRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.ElideRight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ElideRight [as 别名]
def paint(self, painter, option, index):
# Add 4px of left an right padding
option.rect.adjust(4, 0, 4, 0)
text = self._text(painter, option, index)
text = option.fontMetrics.elidedText(text, Qt.ElideRight,
option.rect.width())
painter.save()
if option.state & QStyle.State_Selected:
painter.setBrush(option.palette.highlight())
pen = painter.pen()
pen.setBrush(option.palette.highlightedText())
painter.setPen(pen)
painter.drawText(option.rect, option.displayAlignment, text)
painter.restore()
示例2: on_player_song_changed
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ElideRight [as 别名]
def on_player_song_changed(self, song):
if song is None:
self.song_source_label.setText('歌曲来源')
self.song_title_label.setText('No song is playing.')
return
source_name_map = {p.identifier: p.name
for p in self._app.library.list()}
font_metrics = QFontMetrics(QApplication.font())
text = '{} - {}'.format(song.title_display, song.artists_name_display)
# width -> three button + source label + text <= progress slider
# three button: 63, source label: 150
elided_text = font_metrics.elidedText(
text, Qt.ElideRight, self.progress_slider.width() - 200)
self.song_source_label.setText(source_name_map[song.source])
self.song_title_label.setText(elided_text)
loop = asyncio.get_event_loop()
loop.create_task(self.update_mv_btn_status(song))
示例3: on_table_selection_changed
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ElideRight [as 别名]
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)
示例4: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ElideRight [as 别名]
def __init__(self, parent=None, elidemode=Qt.ElideRight):
super().__init__(parent)
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
self._elidemode = elidemode
self._elided_text = ''
示例5: clipText
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ElideRight [as 别名]
def clipText(self, text: str, painter: QPainter, chapter: bool=False) -> str:
metrics = painter.fontMetrics()
return metrics.elidedText(text, Qt.ElideRight, (self.parent.width() - 10 if chapter else 100 - 10))
示例6: __set_elided_text
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ElideRight [as 别名]
def __set_elided_text(self):
fm = QFontMetrics(self.font())
super().setText(fm.elidedText(self.full_text, Qt.ElideRight, self.width()))
self.setToolTip(self.full_text)