本文整理汇总了Python中PyQt5.Qt.QToolTip类的典型用法代码示例。如果您正苦于以下问题:Python QToolTip类的具体用法?Python QToolTip怎么用?Python QToolTip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QToolTip类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: helpEvent
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: init_ui
def init_ui(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.statusBar().showMessage('Ready')
self.create_widgets()
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Chat')
self.show()
示例3: helpEvent
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: show_tooltip
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()
示例5: __init__
def __init__(self, parent=None):
super(MessageLabel, self).__init__(parent)
palette = QToolTip.palette()
color = QColor(Qt.yellow)
palette.setColor(QPalette.Window, color)
self.setPalette(palette)
self.setAutoFillBackground(True)
self.setFrameStyle(QFrame.Box | QFrame.Plain)
self.setWordWrap(True)
self.hide()
示例6: make_labels
def make_labels(self, target):
""" Create labels for the web nodes in 'source'; if not defined,
find all visible anchor nodes first
TODO pass a color? for 'title' tags
NAV11 DOM01
"""
if target == "links":
source = self.__find_visible(navigables=True)
self.attr.clear('find_titles')
elif target == "titles":
source = self.__find_visible(navigables=False)
self.attr.insert('find_titles')
self.map_tags = dict(zip(ALL_TAGS, source))
for tag, node in self.map_tags.items():
label = QLabel(tag, parent=self)
self.__labels.append(label)
palette = QToolTip.palette()
color = QColor(Qt.yellow)
color = color.lighter(160)
color.setAlpha(196)
palette.setColor(QPalette.Window, color)
label.setPalette(palette)
label.setAutoFillBackground(True)
label.setFrameStyle(QFrame.Box | QFrame.Plain)
point = QPoint(
node.geometry().left(),
node.geometry().center().y())
point -= self.page().mainFrame().scrollPosition()
label.move(point)
label.show()
label.move(label.x(), label.y() + label.height() // 4)
示例7: __init__
def __init__(self, parent=None):
super(NotifyLabel, self).__init__(parent)
print("NOTIFYLABEL", self, parent)
palette = QToolTip.palette()
color = QColor(Qt.blue)
color = color.lighter(170)
color.setAlpha(128)
palette.setColor(QPalette.Window, color)
self.setPalette(palette)
self.setAutoFillBackground(True)
self.setFrameStyle(QFrame.Box | QFrame.Plain)
self.setFont(QFont(None, 20, QFont.Bold))
self.hide()
self.content = deque(maxlen=4)
示例8: collapse_menu_hovered
def collapse_menu_hovered(self, action):
tip = action.toolTip()
if tip == '*':
tip = ''
QToolTip.showText(QCursor.pos(), tip)
示例9: show_tooltip
def show_tooltip(self, arg):
widget, pos = arg
QToolTip.showText(pos, self.get_tooltip())