当前位置: 首页>>代码示例>>Python>>正文


Python QToolTip.showText方法代码示例

本文整理汇总了Python中PyQt4.Qt.QToolTip.showText方法的典型用法代码示例。如果您正苦于以下问题:Python QToolTip.showText方法的具体用法?Python QToolTip.showText怎么用?Python QToolTip.showText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.Qt.QToolTip的用法示例。


在下文中一共展示了QToolTip.showText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: helpEvent

# 需要导入模块: from PyQt4.Qt import QToolTip [as 别名]
# 或者: from PyQt4.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
开发者ID:shamray,项目名称:calibre,代码行数:35,代码来源:alternate_views.py

示例2: show_tooltip

# 需要导入模块: from PyQt4.Qt import QToolTip [as 别名]
# 或者: from PyQt4.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))
     QToolTip.hideText()
     ev.ignore()
开发者ID:BatteringRam,项目名称:calibre,代码行数:13,代码来源:text.py

示例3: maybeTip

# 需要导入模块: from PyQt4.Qt import QToolTip [as 别名]
# 或者: from PyQt4.Qt.QToolTip import showText [as 别名]
   def maybeTip(self, helpEvent):
       """
       Determines if this tooltip should be displayed. The tooltip will be displayed at
       <cusorPos> if an object is highlighted and the mouse hasn't moved for 
       some period of time, called the "wake up delay" period, which is a user pref
       (not yet implemented in the Preferences dialog) currently set to 1 second.
       
       <cursorPos> is the current cursor position in the GLPane's local coordinates.
       
       maybeTip() is called by GLPane.timerEvent() whenever the cursor is not moving to 
       determine if the tooltip should be displayed.
       
       For more details about this member, see Qt documentation on QToolTip.maybeTip().
       """
       
       # <motionlessCursorDuration> is the amount of time the cursor (mouse) has been motionless.
       motionlessCursorDuration = time.time() - self.glpane.cursorMotionlessStartTime
       
       # Don't display the tooltip yet if <motionlessCursorDuration> hasn't exceeded the "wake up delay".
       # The wake up delay is currently set to 1 second in prefs_constants.py. Mark 060818.
       if motionlessCursorDuration < env.prefs[dynamicToolTipWakeUpDelay_prefs_key]:
           self.toolTipShown = False
           return
       
       selobj = self.glpane.selobj
       
       # If an object is not currently highlighted, don't display a tooltip.
       if not selobj:
           return
       
       # If the highlighted object is a singlet, 
       # don't display a tooltip for it.
       if isinstance(selobj, Atom) and (selobj.element is Singlet):
           return
           
       if self.toolTipShown:
           # The tooltip is already displayed, so return. 
           # Do not allow tip() to be called again or it will "flash".
           return
                  
 
       tipText = self.getToolTipText()
       
       if not tipText:            
           tipText = "" 
           # This makes sure that dynamic tip is not displayed when
           # the highlightable object is 'unknown' to the dynamic tip class.
           # (From QToolTip.showText doc: "If text is empty the tool tip is hidden.")
       
       
       QToolTip.showText(helpEvent.globalPos(), tipText)  #@@@ ninad061107 works fine but need code review
              
       self.toolTipShown = True
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:55,代码来源:DynamicTip.py

示例4: helpEvent

# 需要导入模块: from PyQt4.Qt import QToolTip [as 别名]
# 或者: from PyQt4.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
         title = db.new_api.field_for('title', book_id)
         authors = db.new_api.field_for('authors', book_id)
         if title and authors:
             title = '<b>%s</b>' % ('\n'.join(wrap(title, 100)))
             authors = '\n'.join(wrap(' & '.join(authors), 100))
             QToolTip.showText(event.globalPos(), '%s<br><br>%s' % (title, authors), view)
             return True
     return False
开发者ID:jackpinto,项目名称:calibre,代码行数:20,代码来源:alternate_views.py

示例5: collapse_menu_hovered

# 需要导入模块: from PyQt4.Qt import QToolTip [as 别名]
# 或者: from PyQt4.Qt.QToolTip import showText [as 别名]
 def collapse_menu_hovered(self, action):
     tip = action.toolTip()
     if tip == '*':
         tip = ''
     QToolTip.showText(QCursor.pos(), tip)
开发者ID:BobPyron,项目名称:calibre,代码行数:7,代码来源:view.py

示例6: show_tooltip

# 需要导入模块: from PyQt4.Qt import QToolTip [as 别名]
# 或者: from PyQt4.Qt.QToolTip import showText [as 别名]
 def show_tooltip(self, arg):
     widget, pos = arg
     QToolTip.showText(pos, self.get_tooltip())
开发者ID:089git,项目名称:calibre,代码行数:5,代码来源:jobs.py

示例7: maybeTip

# 需要导入模块: from PyQt4.Qt import QToolTip [as 别名]
# 或者: from PyQt4.Qt.QToolTip import showText [as 别名]

#.........这里部分代码省略.........
            whichbuff = {GL_FRONT:"front", GL_BACK:"back"}.get(savebuff, "unknown")
            redraw_counter = env.redraw_counter
            # Pixel data is sign-wrapped, in spite of specifying unsigned_byte.
            def us(b):
                if b < 0:
                    return 256 + b
                else:
                    return b
            def pixvals(buff):
                glReadBuffer(buff)
                gl_format, gl_type = GL_RGBA, GL_UNSIGNED_BYTE
                rgba = glReadPixels( wX, wY, 1, 1, gl_format, gl_type )[0][0]
                return (
                    "rgba %u, %u, %u, %u" %
                    (us(rgba[0]), us(rgba[1]), us(rgba[2]), us(rgba[3]))
                 )
            def redifnot(v1, v2, text):
                if v1 != v2:
                    return redmsg(text)
                else:
                    return text
            front_pixvals = pixvals(GL_FRONT)
            back_pixvals = pixvals(GL_BACK)
            glReadBuffer(savebuff)      # restore the saved value
            tipText = (
                "env.redraw = %d; selobj = %s<br>" % (redraw_counter, quote_html(str(selobj)),) +
                    # note: sometimes selobj is an instance of _UNKNOWN_SELOBJ_class... relates to testmode bug from renderText
                    # (confirmed that renderText zaps stencil and that that alone causes no bug in other graphicsmodes)
                    # TODO: I suspect this can be printed even during rendering... need to print glpane variables
                    # which indicate whether we're doing rendering now, e.g. current_glselect, drawing_phase;
                    # also modkeys (sp?), glselect_wanted
                "mouse position (xy): %d, %d<br>" % (wX, wY,) +
                "depth %f, stencil %d<br>" % (wZ, stencil) +
                redifnot(whichbuff, "back",
                         "current read buffer: %s<br>" % whichbuff ) +
                redifnot(glpane.glselect_wanted, 0,
                         "glselect_wanted: %s<br>" % (glpane.glselect_wanted,) ) +
                redifnot(glpane.current_glselect, False,
                         "current_glselect: %s<br>" % (glpane.current_glselect,) ) +
                redifnot(glpane.drawing_phase, "?",
                         "drawing_phase: %s<br>" % (glpane.drawing_phase,) ) +
                "front: " + front_pixvals + "<br>" +
                redifnot(back_pixvals, front_pixvals,
                         "back:  " + back_pixvals )
             )
            global _last_tipText
            if tipText != _last_tipText:
                print
                print tipText
                _last_tipText = tipText
            pass # use tipText below

        else:

            # <motionlessCursorDuration> is the amount of time the cursor (mouse) has been motionless.
            motionlessCursorDuration = time.time() - glpane.cursorMotionlessStartTime

            # Don't display the tooltip yet if <motionlessCursorDuration> hasn't exceeded the "wake up delay".
            # The wake up delay is currently set to 1 second in prefs_constants.py. Mark 060818.
            if motionlessCursorDuration < env.prefs[dynamicToolTipWakeUpDelay_prefs_key]:
                self.toolTipShown = False
                return

            # If an object is not currently highlighted, don't display a tooltip.
            if not selobj:
                return

            # If the highlighted object is a singlet,
            # don't display a tooltip for it.
            if isinstance(selobj, Atom) and (selobj.element is Singlet):
                return

            if self.toolTipShown:
                # The tooltip is already displayed, so return.
                # Do not allow tip() to be called again or it will "flash".
                return

            tipText = self._getToolTipText()

            pass

        # show the tipText

        if not tipText:
            tipText = ""
            # This makes sure that dynamic tip is not displayed when
            # the highlightable object is 'unknown' to the dynamic tip class.
            # (From QToolTip.showText doc: "If text is empty the tool tip is hidden.")

        showpos = helpEvent.globalPos()

        if debug:
            # show it a little lower to avoid the cursor obscuring the tooltip.
            # (might be useful even when not debugging, depending on the cursor)
            # [bruce 081208]
            showpos = showpos + QPoint(0, 10)

        QToolTip.showText(showpos, tipText)  #@@@ ninad061107 works fine but need code review

        self.toolTipShown = True
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:104,代码来源:DynamicTip.py


注:本文中的PyQt4.Qt.QToolTip.showText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。