You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to delete an empty listbox using listbox.delete("all", tkinter.END) you get this error:
line 178, in deselect
if self.buttons[index] in self.selections:
~~~~~~~~~~~~^^^^^^^
KeyError: 0
The text was updated successfully, but these errors were encountered:
I was able to fix it by changing the deselect function: def deselect(self, index): if not self.multiple: if self.selected: self.selected.configure(fg_color=self.button_fg_color) self.selected = None return if index in self.buttons and self.buttons[index] in self.selections: self.selections.remove(self.buttons[index]) self.buttons[index].configure(fg_color=self.button_fg_color)
Prettier printed (BTW I also struggle with the GitHub editor ! ;)):
def deselect(self, index):
if not self.multiple:
if self.selected:
self.selected.configure(fg_color=self.button_fg_color)
self.selected = None
return
if index in self.buttons and self.buttons[index] in self.selections:
self.selections.remove(self.buttons[index])
self.buttons[index].configure(fg_color=self.button_fg_color)
If you try to delete an empty listbox using listbox.delete("all", tkinter.END) you get this error:
line 178, in deselect
if self.buttons[index] in self.selections:
~~~~~~~~~~~~^^^^^^^
KeyError: 0
The text was updated successfully, but these errors were encountered: