(self, encoding)
Set the current selected encoding.

        Parameters
        ----------
        encoding : str
            Encoding name such that `codecs.lookup` finds it.
Set the current selected encoding.
Set the current selected encoding .
def setSelectedEncoding(self, encoding):
        # type: (str) -> None
        """
        Set the current selected encoding.

        Parameters
        ----------
        encoding : str
            Encoding name such that `codecs.lookup` finds it.
        """
        co = codecs.lookup(encoding)
        cb = self.encoding_cb
        index = cb.findData(co.name, Qt.UserRole)

        if index == -1:
            # insert the encoding before the separator.
            sepidx = cb.findData("separator", Qt.AccessibleDescriptionRole)
            if sepidx == -1:
                sepidx = cb.count()
            cb.insertItem(sepidx, encodings.display_name(co.name),
                          userData=co.name)
            index = sepidx
            assert cb.itemData(index, Qt.UserRole) == co.name
            changed = True
            self._encoding = encoding
        else:
            changed = index != self.encoding_cb.currentIndex()
            self._encoding = encoding

        self.encoding_cb.setCurrentIndex(index)

        if changed:
            self.optionsChanged.emit()
def setSelectedEncoding ( self , encoding ) : # type: (str) -> None co = codecs . lookup ( encoding ) cb = self . encoding_cb index = cb . findData ( co . name , Qt . UserRole ) if index == - 1 : # insert the encoding before the separator. sepidx = cb . findData ( "separator" , Qt . AccessibleDescriptionRole ) if sepidx == - 1 : sepidx = cb . count ( ) cb . insertItem ( sepidx , encodings . display_name ( co . name ) , userData = co . name ) index = sepidx assert cb . itemData ( index , Qt . UserRole ) == co . name changed = True self . _encoding = encoding else : changed = index != self . encoding_cb . currentIndex ( ) self . _encoding = encoding self . encoding_cb . setCurrentIndex ( index ) if changed : self . optionsChanged . emit ( )