本文整理匯總了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())