(view, menu)
Add 'lookup' action to context menu
Add 'lookup' action to context menu
Add lookup action to context menu
def addToContextMenu(view, menu):
    """Add 'lookup' action to context menu"""
    if USE_CUSTOM_STYLESHEET:
        menu.setStyleSheet(stylesheet)
    selected = view.page().selectedText()
    if not selected:
        return
    
    suffix = (selected[:20] + '..') if len(selected) > 20 else selected
    label = u'Search for "%s" in Card &Browser' % suffix
    menu.addSeparator()
    a = menu.addAction(label)
    a.triggered.connect(lambda _, t=selected: lookup_browser(t))

    search_menu = None
    if len(SEARCH_PROVIDERS) > 10:  
        search_menu = menu.addMenu(u'&Search for "%s" with...' % suffix)

    for idx, provider in enumerate(SEARCH_PROVIDERS):
        if search_menu:
            label = provider[0]
            menu = search_menu
        else:
            label = u'Search for "%s" on %s' % (suffix, provider[0])
        a = menu.addAction(label)
        a.triggered.connect(lambda _, i=idx,t=selected: lookup_online(t, i))
def addToContextMenu ( view , menu ) : if USE_CUSTOM_STYLESHEET : menu . setStyleSheet ( stylesheet ) selected = view . page ( ) . selectedText ( ) if not selected : return suffix = ( selected [ : 20 ] + '..' ) if len ( selected ) > 20 else selected label = u'Search for "%s" in Card &Browser' % suffix menu . addSeparator ( ) a = menu . addAction ( label ) a . triggered . connect ( lambda _ , t = selected : lookup_browser ( t ) ) search_menu = None if len ( SEARCH_PROVIDERS ) > 10 : search_menu = menu . addMenu ( u'&Search for "%s" with...' % suffix ) for idx , provider in enumerate ( SEARCH_PROVIDERS ) : if search_menu : label = provider [ 0 ] menu = search_menu else : label = u'Search for "%s" on %s' % ( suffix , provider [ 0 ] ) a = menu . addAction ( label ) a . triggered . connect ( lambda _ , i = idx , t = selected : lookup_online ( t , i ) )