當前位置: 首頁>>代碼示例>>Python>>正文


Python Qt.QToolTip類代碼示例

本文整理匯總了Python中PyQt4.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
開發者ID:shamray,項目名稱:calibre,代碼行數:33,代碼來源:alternate_views.py

示例2: maybeTip

   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,代碼行數:53,代碼來源:DynamicTip.py

示例3: 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
         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,代碼行數:18,代碼來源:alternate_views.py

示例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))
     QToolTip.hideText()
     ev.ignore()
開發者ID:BatteringRam,項目名稱:calibre,代碼行數:11,代碼來源:text.py

示例5: languageChange

    def languageChange(self):
        opts = self.desc.option_attrs
        
        self.setCaption(QtGui.QApplication.translate(self.__class__.__name__, opts.caption)) # was "Nanotube"
        self.heading_label.setText(QtGui.QApplication.translate(self.__class__.__name__, opts.title)) # was "Nanotube"
        self.sponsor_btn.setText(QString.null)
        
        self.done_btn.setText(QString.null)
        QToolTip.add(self.done_btn,QtGui.QApplication.translate(self.__class__.__name__, "Done"))
        
        self.abort_btn.setText(QString.null)
        QToolTip.add(self.abort_btn,QtGui.QApplication.translate(self.__class__.__name__, "Cancel"))
        
        self.preview_btn.setText(QString.null)
        QToolTip.add(self.preview_btn,QtGui.QApplication.translate(self.__class__.__name__, "Preview"))
        
        self.whatsthis_btn.setText(QString.null)
        QToolTip.add(self.whatsthis_btn,QtGui.QApplication.translate(self.__class__.__name__, "What's This Help"))

        ### move these up:
##        if 0:
##            self.parameters_grpbox.setTitle(QString.null)
##            self.nt_parameters_grpbtn.setText(QString.null)
##            self.parameters_grpbox_label.setText(QtGui.QApplication.translate(self.__class__.__name__, "Nanotube Parameters"))

##        if 0:
##            self.members_label.setText(QtGui.QApplication.translate(self.__class__.__name__, "Members :"))
##            self.length_label.setText(QtGui.QApplication.translate(self.__class__.__name__, "Length :"))
##            self.chirality_n_label.setText(QtGui.QApplication.translate(self.__class__.__name__, "Chirality (n) :"))
##            self.members_combox.clear()
##            self.members_combox.insertItem(QtGui.QApplication.translate(self.__class__.__name__, "C - C"))
##            self.members_combox.insertItem(QtGui.QApplication.translate(self.__class__.__name__, "B - N"))
##            self.length_linedit.setText(QtGui.QApplication.translate(self.__class__.__name__, "20.0 A"))
##            self.chirality_N_spinbox.setSuffix(QString.null)

        self.cancel_btn.setText(QtGui.QApplication.translate(self.__class__.__name__, "Cancel"))
        self.ok_btn.setText(QtGui.QApplication.translate(self.__class__.__name__, "OK"))
        return
開發者ID:elfion,項目名稱:nanoengineer,代碼行數:38,代碼來源:ParameterDialog.py

示例6: __init__


#.........這裏部分代碼省略.........
                    header_refs.append(controller)
                    getter = controller.get_value
                    
                elif param.isa('parameter', widget = ('spinbox', None), type = 'int') or \
                     param.isa('parameter', widget = ('spinbox'), type = None):
                    self.chirality_N_spinbox = QSpinBox(self.parameters_grpbox,"chirality_N_spinbox") # was chirality_m_spinbox, now chirality_N_spinbox
                    editfield = self.chirality_N_spinbox
                    ### seems like Qt defaults for min and max are 0,100 -- way too small a range!
                    if param.options.has_key('min') or 1:
                        self.chirality_N_spinbox.setMinimum(param.options.get('min', -999999999)) # was 0
                    if param.options.has_key('max') or 1:
                        self.chirality_N_spinbox.setMaximum(param.options.get('max', +999999999)) # wasn't in egcode, but needed
                    self.chirality_N_spinbox.setValue(param.options.get('default', 0)) # was 5
                        ##e note: i suspect this default 0 should come from something that knows this desc grammar.
                    suffix = param.options.get('suffix', '')
                    if suffix:
                        self.chirality_N_spinbox.setSuffix(QtGui.QApplication.translate(self.__class__.__name__, suffix))
                    else:
                        self.chirality_N_spinbox.setSuffix(QString.null) # probably not needed
                    nt_parameters_body_layout.addWidget(self.chirality_N_spinbox,thisrow,1)
                    hidethese.append(self.chirality_N_spinbox)
                    getter = self.chirality_N_spinbox.value # note: it also has .text, which includes suffix
                    
                else:
                    print "didn't match:",param ###e improve this

                # things done the same way for all kinds of param-editing widgets
                if 1: #bruce 060703 moved this down here, as bugfix
                    # set tooltip (same one for editfield and label)
                    tooltip = param.options.get('tooltip', '')
                    ###e do it for more kinds of params; share the code somehow; do it in controller, or setup-aid?
                    ###k QToolTip appropriateness; tooltip option might be entirely untested
                    if tooltip and label:
                        QToolTip.add(label, QtGui.QApplication.translate(self.__class__.__name__, tooltip))
                    if tooltip and editfield:
                        QToolTip.add(editfield, QtGui.QApplication.translate(self.__class__.__name__, tooltip)) ##k ok?? review once not all params have same-row labels.
                
                if getter and paramname and paramname != '?':
                    self.param_getters[paramname] = getter
                ### also bind these params to actions...
                continue # next param

            header_refs.extend( [self.parameters_grpbox, self.nt_parameters_grpbtn, self.parameters_grpbox_label] )
            
            # now create the logic/control object for the group
            group = CollapsibleGroupController_Qt(self, group_desc, header_refs, hidethese, self.nt_parameters_grpbtn)
                ### maybe ask env for the class to use for this?
            self.groups.append(group) ### needed?? only for scanning the params, AFAIK -- oh, and to maintain a python refcount.

            # from languageChange:
            if 1: # i don't know if these are needed:
                self.parameters_grpbox.setTitle(QString.null)
                self.nt_parameters_grpbtn.setText(QString.null)
            self.parameters_grpbox_label.setText(QtGui.QApplication.translate(self.__class__.__name__, group_desc.args[0])) # was "Nanotube Parameters"
                ##e note that it's questionable in the syntax design for this property of a group (overall group label)
                # to be in that position (desc arg 0).
        
            # == end its kids
            
            parameters_grpboxLayout.addLayout(nt_parameters_body_layout)
            body_frameLayout.addWidget(self.parameters_grpbox)

            # == end parameters groupbox
            
            continue # next group
開發者ID:elfion,項目名稱:nanoengineer,代碼行數:66,代碼來源:ParameterDialog.py

示例7: collapse_menu_hovered

 def collapse_menu_hovered(self, action):
     tip = action.toolTip()
     if tip == '*':
         tip = ''
     QToolTip.showText(QCursor.pos(), tip)
開發者ID:BobPyron,項目名稱:calibre,代碼行數:5,代碼來源:view.py

示例8: show_tooltip

 def show_tooltip(self, arg):
     widget, pos = arg
     QToolTip.showText(pos, self.get_tooltip())
開發者ID:089git,項目名稱:calibre,代碼行數:3,代碼來源:jobs.py

示例9: maybeTip


#.........這裏部分代碼省略.........
            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,代碼行數:101,代碼來源:DynamicTip.py


注:本文中的PyQt4.Qt.QToolTip類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。