(self)
Call when the selection of the Listbox has changed.

        Updates the Listbox display and calls _change_start.
Call when the selection of the Listbox has changed.
Call when the selection of the Listbox has changed .
def _selection_changed(self):
        """Call when the selection of the Listbox has changed.

        Updates the Listbox display and calls _change_start.
        """
        cursel = int(self.listbox.curselection()[0])

        self.listbox.see(cursel)

        lts = self.lasttypedstart
        selstart = self.completions[cursel]
        if self._binary_search(lts) == cursel:
            newstart = lts
        else:
            min_len = min(len(lts), len(selstart))
            i = 0
            while i < min_len and lts[i] == selstart[i]:
                i += 1
            newstart = selstart[:i]
        self._change_start(newstart)

        if self.completions[cursel][:len(self.start)] == self.start:
            # start is a prefix of the selected completion
            self.listbox.configure(selectbackground=self.origselbackground,
                                   selectforeground=self.origselforeground)
        else:
            self.listbox.configure(selectbackground=self.listbox.cget("bg"),
                                   selectforeground=self.listbox.cget("fg"))
            # If there are more completions, show them, and call me again.
            if self.morecompletions:
                self.completions = self.morecompletions
                self.morecompletions = None
                self.listbox.delete(0, END)
                for item in self.completions:
                    self.listbox.insert(END, item)
                self.listbox.select_set(self._binary_search(self.start))
                self._selection_changed()
def _selection_changed ( self ) : cursel = int ( self . listbox . curselection ( ) [ 0 ] ) self . listbox . see ( cursel ) lts = self . lasttypedstart selstart = self . completions [ cursel ] if self . _binary_search ( lts ) == cursel : newstart = lts else : min_len = min ( len ( lts ) , len ( selstart ) ) i = 0 while i < min_len and lts [ i ] == selstart [ i ] : i += 1 newstart = selstart [ : i ] self . _change_start ( newstart ) if self . completions [ cursel ] [ : len ( self . start ) ] == self . start : # start is a prefix of the selected completion self . listbox . configure ( selectbackground = self . origselbackground , selectforeground = self . origselforeground ) else : self . listbox . configure ( selectbackground = self . listbox . cget ( "bg" ) , selectforeground = self . listbox . cget ( "fg" ) ) # If there are more completions, show them, and call me again. if self . morecompletions : self . completions = self . morecompletions self . morecompletions = None self . listbox . delete ( 0 , END ) for item in self . completions : self . listbox . insert ( END , item ) self . listbox . select_set ( self . _binary_search ( self . start ) ) self . _selection_changed ( )