Call when the selection of the Listbox has changed. Updates the Listbox display and calls _change_start.
(self)
| 121 | return first_comp[:i] |
| 122 | |
| 123 | def _selection_changed(self): |
| 124 | """Call when the selection of the Listbox has changed. |
| 125 | |
| 126 | Updates the Listbox display and calls _change_start. |
| 127 | """ |
| 128 | cursel = int(self.listbox.curselection()[0]) |
| 129 | |
| 130 | self.listbox.see(cursel) |
| 131 | |
| 132 | lts = self.lasttypedstart |
| 133 | selstart = self.completions[cursel] |
| 134 | if self._binary_search(lts) == cursel: |
| 135 | newstart = lts |
| 136 | else: |
| 137 | min_len = min(len(lts), len(selstart)) |
| 138 | i = 0 |
| 139 | while i < min_len and lts[i] == selstart[i]: |
| 140 | i += 1 |
| 141 | newstart = selstart[:i] |
| 142 | self._change_start(newstart) |
| 143 | |
| 144 | if self.completions[cursel][:len(self.start)] == self.start: |
| 145 | # start is a prefix of the selected completion |
| 146 | self.listbox.configure(selectbackground=self.origselbackground, |
| 147 | selectforeground=self.origselforeground) |
| 148 | else: |
| 149 | self.listbox.configure(selectbackground=self.listbox.cget("bg"), |
| 150 | selectforeground=self.listbox.cget("fg")) |
| 151 | # If there are more completions, show them, and call me again. |
| 152 | if self.morecompletions: |
| 153 | self.completions = self.morecompletions |
| 154 | self.morecompletions = None |
| 155 | self.listbox.delete(0, END) |
| 156 | for item in self.completions: |
| 157 | self.listbox.insert(END, item) |
| 158 | self.listbox.select_set(self._binary_search(self.start)) |
| 159 | self._selection_changed() |
| 160 | |
| 161 | def show_window(self, comp_lists, index, complete, mode, userWantsWin): |
| 162 | """Show the autocomplete list, bind events. |
no test coverage detected