本文整理汇总了Python中PyQt5.Qt.QToolTip.showText方法的典型用法代码示例。如果您正苦于以下问题:Python QToolTip.showText方法的具体用法?Python QToolTip.showText怎么用?Python QToolTip.showText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QToolTip
的用法示例。
在下文中一共展示了QToolTip.showText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: helpEvent
# 需要导入模块: from PyQt5.Qt import QToolTip [as 别名]
# 或者: from PyQt5.Qt.QToolTip import showText [as 别名]
def helpEvent(self, event, view, option, index):
if event is not None and view is not None and event.type() == QEvent.ToolTip:
try:
db = index.model().db
except AttributeError:
return False
try:
book_id = db.id(index.row())
except (ValueError, IndexError, KeyError):
return False
db = db.new_api
device_connected = self.parent().gui.device_connected
on_device = device_connected is not None and db.field_for('ondevice', book_id)
p = prepare_string_for_xml
title = db.field_for('title', book_id)
authors = db.field_for('authors', book_id)
if title and authors:
title = '<b>%s</b>' % ('<br>'.join(wrap(p(title), 120)))
authors = '<br>'.join(wrap(p(' & '.join(authors)), 120))
tt = '%s<br><br>%s' % (title, authors)
series = db.field_for('series', book_id)
if series:
use_roman_numbers=config['use_roman_numerals_for_series_number']
val = _('Book %(sidx)s of <span class="series_name">%(series)s</span>')%dict(
sidx=fmt_sidx(db.field_for('series_index', book_id), use_roman=use_roman_numbers),
series=p(series))
tt += '<br><br>' + val
if on_device:
val = _('This book is on the device in %s') % on_device
tt += '<br><br>' + val
QToolTip.showText(event.globalPos(), tt, view)
return True
return False
示例2: show_tooltip
# 需要导入模块: from PyQt5.Qt import QToolTip [as 别名]
# 或者: from PyQt5.Qt.QToolTip import showText [as 别名]
def show_tooltip(self, ev):
c = self.cursorForPosition(ev.pos())
fmt = self.syntax_format_for_cursor(c)
if fmt is not None:
tt = unicode(fmt.toolTip())
if tt:
QToolTip.setFont(self.tooltip_font)
QToolTip.setPalette(self.tooltip_palette)
QToolTip.showText(ev.globalPos(), textwrap.fill(tt))
return
QToolTip.hideText()
ev.ignore()
示例3: helpEvent
# 需要导入模块: from PyQt5.Qt import QToolTip [as 别名]
# 或者: from PyQt5.Qt.QToolTip import showText [as 别名]
def helpEvent(self, ev, view, option, index):
# Show a tooltip only if the item is truncated
if not ev or not view:
return False
if ev.type() == ev.ToolTip:
rect = view.visualRect(index)
size = self.sizeHint(option, index)
if rect.width() < size.width():
tooltip = index.data(Qt.DisplayRole)
QToolTip.showText(ev.globalPos(), tooltip, view)
return True
return QStyledItemDelegate.helpEvent(self, ev, view, option, index)
示例4: collapse_menu_hovered
# 需要导入模块: from PyQt5.Qt import QToolTip [as 别名]
# 或者: from PyQt5.Qt.QToolTip import showText [as 别名]
def collapse_menu_hovered(self, action):
tip = action.toolTip()
if tip == '*':
tip = ''
QToolTip.showText(QCursor.pos(), tip)
示例5: show_tooltip
# 需要导入模块: from PyQt5.Qt import QToolTip [as 别名]
# 或者: from PyQt5.Qt.QToolTip import showText [as 别名]
def show_tooltip(self, arg):
widget, pos = arg
QToolTip.showText(pos, self.get_tooltip())