def get(self, index=None):
""" get the selected value """
if index:
if str(index).lower()=="all":
return list(item.cget("text") for item in self.buttons.values())
else:
index = list(self.buttons.keys())[int(index)]
return self.buttons[index].cget("text")
else:
if self.multiple:
return [x.cget("text") for x in self.selections] if len(self.selections)>0 else None
else:
return self.selected.cget("text") if self.selected is not None else None
It could deliver the value from all indexes above 1 back to the program, except 0.
It was really frustrating when trying to remove multiple items in the list but I couldn't grab the first item in the list.
This is a revised version that did the trick:
def get(self, index=None):
""" get the selected value """
if index is not None: # Changed this line
if str(index).lower() == "all":
return list(item.cget("text") for item in self.buttons.values())
else:
index = list(self.buttons.keys())[int(index)]
return self.buttons[index].cget("text")
else:
if self.multiple:
return [x.cget("text") for x in self.selections] if len(self.selections) > 0 else None
else:
return self.selected.cget("text") if self.selected is not None else None
It could deliver the value from all indexes above 1 back to the program, except 0.
It was really frustrating when trying to remove multiple items in the list but I couldn't grab the first item in the list. This is a revised version that did the trick: