March 2018
Beginner to intermediate
422 pages
10h 33m
English
Since the Listbox allows for multiple selections, we iterate through all the selected items, removing them from the frontend Listbox widget as well as from the model play_list, as follows (see code 5.03—view.py):
def remove_selected_files(self): try: selected_indexes = self.list_box.curselection() for index in reversed(selected_indexes): self.list_box.delete(index) self.model.remove_item_from_play_list_at_index(index) except IndexError: pass
Note that we reverse the tuple before removing items from the playlist because we want to start removing items from the end, as a removal causes a change in the index of playlist items. If we do not remove items from the end, we may end up removing the wrong ...
Read now
Unlock full access