本文整理汇总了Python中spyderlib.qt.QtGui.QToolTip类的典型用法代码示例。如果您正苦于以下问题:Python QToolTip类的具体用法?Python QToolTip怎么用?Python QToolTip使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QToolTip类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_warning
def update_warning(self):
""" """
widget = self._button_warning
if not self.is_valid():
tip = _('Array dimensions not valid')
widget.setIcon(ima.icon('MessageBoxWarning'))
widget.setToolTip(tip)
QToolTip.showText(self._widget.mapToGlobal(QPoint(0, 5)), tip)
else:
self._button_warning.setToolTip('')
示例2: hide_tooltip_if_necessary
def hide_tooltip_if_necessary(self, key):
"""Hide calltip when necessary"""
try:
calltip_char = self.get_character(self.calltip_position)
before = self.is_cursor_before(self.calltip_position, char_offset=1)
other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab)
if calltip_char not in ("?", "(") or before or other:
QToolTip.hideText()
except (IndexError, TypeError):
QToolTip.hideText()
示例3: keyPressEvent
def keyPressEvent(self, event):
"""Override Qt method"""
QToolTip.hideText()
ctrl = event.modifiers() & Qt.ControlModifier
if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
if ctrl:
self.process_text(array=False)
else:
self.process_text(array=True)
self.accept()
else:
QDialog.keyPressEvent(self, event)
示例4: show_calltip
def show_calltip(self, title, text, signature=False, color='#2D62FF',
at_line=None, at_position=None):
"""Show calltip"""
if text is None or len(text) == 0:
return
# Saving cursor position:
if at_position is None:
at_position = self.get_position('cursor')
self.calltip_position = at_position
# Preparing text:
if signature:
text, wrapped_textlines = self._format_signature(text)
else:
if isinstance(text, list):
text = "\n ".join(text)
text = text.replace('\n', '<br>')
if len(text) > self.calltip_size:
text = text[:self.calltip_size] + " ..."
# Formatting text
font = self.font()
size = font.pointSize()
family = font.family()
format1 = '<div style=\'font-family: "%s"; font-size: %spt; color: %s\'>'\
% (family, size, color)
format2 = '<div style=\'font-family: "%s"; font-size: %spt\'>'\
% (family, size-1 if size > 9 else size)
tiptext = format1 + ('<b>%s</b></div>' % title) + '<hr>' + \
format2 + text + "</div>"
# Showing tooltip at cursor position:
cx, cy = self.get_coordinates('cursor')
if at_line is not None:
cx = 5
cursor = QTextCursor(self.document().findBlockByNumber(at_line-1))
cy = self.cursorRect(cursor).top()
point = self.mapToGlobal(QPoint(cx, cy))
point.setX(point.x()+self.get_linenumberarea_width())
point.setY(point.y()+font.pointSize()+5)
if signature:
self.calltip_widget.show_tip(point, tiptext, wrapped_textlines)
else:
QToolTip.showText(point, tiptext)
示例5: update_warning
def update_warning(self, reset=False):
""" """
conflicts = self.check_conflicts()
if reset:
conflicts = []
widget = self.helper_button
if conflicts:
tip_title = _('The new entered shorcut conflicts with:') + '\n'
tip_body = ''
for s in conflicts:
tip_body += ' - {0}: {1}\n'.format(s.context, s.name)
tip = '{0}{1}'.format(tip_title, tip_body)
widget.setIcon(get_std_icon('MessageBoxWarning'))
widget.setToolTip(tip)
QToolTip.showText(widget.mapToGlobal(QPoint(0, 5)), tip)
else:
widget.setToolTip('')
QToolTip.hideText()
widget.setIcon(get_std_icon('DialogApplyButton'))
示例6: show_tip
def show_tip(self, tip=""):
"""Show tip"""
QToolTip.showText(self.mapToGlobal(self.pos()), tip, self)
示例7: postprocess_keyevent
def postprocess_keyevent(self, event):
"""Process keypress event"""
ShellBaseWidget.postprocess_keyevent(self, event)
if QToolTip.isVisible():
_event, _text, key, _ctrl, _shift = restore_keyevent(event)
self.hide_tooltip_if_necessary(key)
示例8: mouseReleaseEvent
def mouseReleaseEvent(self, event):
QToolTip.showText(self.mapToGlobal(QPoint(0, self.height())),
self._tip_text)
示例9: mousePressEvent
def mousePressEvent(self, event):
QToolTip.hideText()
示例10: mouseReleaseEvent
def mouseReleaseEvent(self, event):
""" """
QToolTip.showText(self.mapToGlobal(QPoint(0, 0)), self._tip_text)