all next and previous track computations will overflow. Computation should be modulus number of tracks
song_index = (self.ui.current_song_number() + 1) % self.ui.song_count()
track label formation catches exceptions but (a) uses a bare
except
, (b) largely repeats the try block in the exception handler, (c) inserts the malformed label and (d) includes a dangling variable name. Perhaps something like this:try: id3 = ID3(file_name) data = id3['TPE1'].text[0] + " - " + id3["TIT2"].text[0] self.filenames_by_track_label[data] = file_name self.ui.listWidget.addItem(data) except (IOError, LookupError): self.ui.show_error("El archivo que ha elegido no funciona. Seleccione otro archivo por favor.")