(model, parent=None, accepted_type=Orange.data.Variable,
                     view_type=VariablesListItemView)
return filter_edit, view
GUI components: ListView with a lineedit which works as a filter. One can write
    a variable name in a edit box and possible matches are then shown in a listview.
GUI components: ListView with a lineedit which works as a filter. One can write
    a variable name in a edit box and possible matches are then shown in a listview.
GUI components : ListView with a lineedit which works as a filter . One can write a variable name in a edit box and possible matches are then shown in a listview .
def variables_filter(model, parent=None, accepted_type=Orange.data.Variable,
                     view_type=VariablesListItemView):
    """
    GUI components: ListView with a lineedit which works as a filter. One can write
    a variable name in a edit box and possible matches are then shown in a listview.
    """
    def update_completer_model():
        """ This gets called when the model for available attributes changes
        through either drag/drop or the left/right button actions.

        """
        nonlocal original_completer_items
        items = ["%s=%s" % item for v in model for item in v.attributes.items()]

        new = sorted(set(items))
        if new != original_completer_items:
            original_completer_items = new
            completer_model.setStringList(original_completer_items)

    def update_completer_prefix():
        """ Prefixes all items in the completer model with the current
        already done completion to enable the completion of multiple keywords.
        """
        nonlocal original_completer_items
        prefix = str(completer.completionPrefix())
        if not prefix.endswith(" ") and " " in prefix:
            prefix, _ = prefix.rsplit(" ", 1)
            items = [prefix + " " + item
                     for item in original_completer_items]
        else:
            items = original_completer_items
        old = list(map(str, completer_model.stringList()))

        if set(old) != set(items):
            completer_model.setStringList(items)

    original_completer_items = []

    filter_edit = QLineEdit()
    filter_edit.setToolTip("Filter the list of available variables.")
    filter_edit.setPlaceholderText("Filter")

    completer_model = QStringListModel()
    completer = QCompleter(completer_model, filter_edit)
    completer.setCompletionMode(QCompleter.InlineCompletion)
    completer.setModelSorting(QCompleter.CaseSensitivelySortedModel)

    filter_edit.setCompleter(completer)
    completer_navigator = CompleterNavigator(parent)
    filter_edit.installEventFilter(completer_navigator)

    proxy = VariableFilterProxyModel()
    proxy.setSourceModel(model)
    view = view_type(acceptedType=accepted_type)
    view.setModel(proxy)

    model.dataChanged.connect(update_completer_model)
    model.rowsInserted.connect(update_completer_model)
    model.rowsRemoved.connect(update_completer_model)

    filter_edit.textChanged.connect(update_completer_prefix)
    filter_edit.textChanged.connect(proxy.set_filter_string)

    return filter_edit, view
def variables_filter ( model , parent = None , accepted_type = Orange . data . Variable , view_type = VariablesListItemView ) : def update_completer_model ( ) : """ This gets called when the model for available attributes changes
        through either drag/drop or the left/right button actions.

        """ nonlocal original_completer_items items = [ "%s=%s" % item for v in model for item in v . attributes . items ( ) ] new = sorted ( set ( items ) ) if new != original_completer_items : original_completer_items = new completer_model . setStringList ( original_completer_items ) def update_completer_prefix ( ) : """ Prefixes all items in the completer model with the current
        already done completion to enable the completion of multiple keywords.
        """ nonlocal original_completer_items prefix = str ( completer . completionPrefix ( ) ) if not prefix . endswith ( " " ) and " " in prefix : prefix , _ = prefix . rsplit ( " " , 1 ) items = [ prefix + " " + item for item in original_completer_items ] else : items = original_completer_items old = list ( map ( str , completer_model . stringList ( ) ) ) if set ( old ) != set ( items ) : completer_model . setStringList ( items ) original_completer_items = [ ] filter_edit = QLineEdit ( ) filter_edit . setToolTip ( "Filter the list of available variables." ) filter_edit . setPlaceholderText ( "Filter" ) completer_model = QStringListModel ( ) completer = QCompleter ( completer_model , filter_edit ) completer . setCompletionMode ( QCompleter . InlineCompletion ) completer . setModelSorting ( QCompleter . CaseSensitivelySortedModel ) filter_edit . setCompleter ( completer ) completer_navigator = CompleterNavigator ( parent ) filter_edit . installEventFilter ( completer_navigator ) proxy = VariableFilterProxyModel ( ) proxy . setSourceModel ( model ) view = view_type ( acceptedType = accepted_type ) view . setModel ( proxy ) model . dataChanged . connect ( update_completer_model ) model . rowsInserted . connect ( update_completer_model ) model . rowsRemoved . connect ( update_completer_model ) filter_edit . textChanged . connect ( update_completer_prefix ) filter_edit . textChanged . connect ( proxy . set_filter_string ) return filter_edit , view