(self, value)
Set the value of control by item labels.

        value is expected to be an iterable of strings that are substrings of
        the item labels that should be selected.  Before substring matching is
        performed, the original label text is whitespace-compressed
        (consecutive whitespace characters are converted to a single space
        character) and leading and trailing whitespace is stripped.  Ambiguous
        labels are accepted without complaint if the form's backwards_compat is
        True; otherwise, it will not complain as long as all ambiguous labels
        share the same item name (e.g. OPTION value).
Set the value of control by item labels.
Set the value of control by item labels .
def set_value_by_label(self, value):
        """Set the value of control by item labels.

        value is expected to be an iterable of strings that are substrings of
        the item labels that should be selected.  Before substring matching is
        performed, the original label text is whitespace-compressed
        (consecutive whitespace characters are converted to a single space
        character) and leading and trailing whitespace is stripped.  Ambiguous
        labels are accepted without complaint if the form's backwards_compat is
        True; otherwise, it will not complain as long as all ambiguous labels
        share the same item name (e.g. OPTION value).

        """
        if isstringlike(value):
            raise TypeError(value)
        if not self.multiple and len(value) > 1:
            raise ItemCountError(
                "single selection list, must set sequence of "
                "length 0 or 1")
        items = []
        for nn in value:
            found = self.get_items(label=nn)
            if len(found) > 1:
                if not self._form.backwards_compat:
                    # ambiguous labels are fine as long as item names (e.g.
                    # OPTION values) are same
                    opt_name = found[0].name
                    if [o for o in found[1:] if o.name != opt_name]:
                        raise AmbiguityError(nn)
                else:
                    # OK, we'll guess :-(  Assume first available item.
                    found = found[:1]
            for o in found:
                # For the multiple-item case, we could try to be smarter,
                # saving them up and trying to resolve, but that's too much.
                if self._form.backwards_compat or o not in items:
                    items.append(o)
                    break
            else:  # all of them are used
                raise ItemNotFoundError(nn)
        # now we have all the items that should be on
        # let's just turn everything off and then back on.
        self.value = []
        for o in items:
            o.selected = True
def set_value_by_label ( self , value ) : if isstringlike ( value ) : raise TypeError ( value ) if not self . multiple and len ( value ) > 1 : raise ItemCountError ( "single selection list, must set sequence of " "length 0 or 1" ) items = [ ] for nn in value : found = self . get_items ( label = nn ) if len ( found ) > 1 : if not self . _form . backwards_compat : # ambiguous labels are fine as long as item names (e.g. # OPTION values) are same opt_name = found [ 0 ] . name if [ o for o in found [ 1 : ] if o . name != opt_name ] : raise AmbiguityError ( nn ) else : # OK, we'll guess :-(  Assume first available item. found = found [ : 1 ] for o in found : # For the multiple-item case, we could try to be smarter, # saving them up and trying to resolve, but that's too much. if self . _form . backwards_compat or o not in items : items . append ( o ) break else : # all of them are used raise ItemNotFoundError ( nn ) # now we have all the items that should be on # let's just turn everything off and then back on. self . value = [ ] for o in items : o . selected = True