diff --git a/src/app/ui/tambah_acara_ui.py b/src/app/ui/tambah_acara_ui.py index 36cf9a7b3609774aae92c0ab1caef4aa45a241e6..3aba5d8712c8454f0c0fe4d920a59a3238316ecf 100644 --- a/src/app/ui/tambah_acara_ui.py +++ b/src/app/ui/tambah_acara_ui.py @@ -98,9 +98,14 @@ class TambahAcaraWindow(QtWidgets.QMainWindow): if len(self.__photos) == 0: self.image.setPixmap(QtGui.QPixmap.fromImage(self.__default_img)) else: - self.image.setPixmap( - QtGui.QPixmap.fromImage( - self.__photos[self.__current_image_counter])) + try: + self.image.setPixmap( + QtGui.QPixmap.fromImage( + self.__photos[self.__current_image_counter])) + except IndexError: + self.image.setPixmap( + QtGui.QPixmap.fromImage( + self.__photos[0])) def __next_image(self): try: @@ -226,8 +231,12 @@ class TambahAcaraWindow(QtWidgets.QMainWindow): if len(self.__photos) > 0: self.__photos.remove(self.__photos[self.__current_image_counter]) self.__current_image_counter -= 1 - self.__current_image_counter %= len(self.__photos) - self.__set_image() + try: + self.__current_image_counter %= len(self.__photos) + except ZeroDivisionError: + self.__current_image_counter = 0 + finally: + self.__set_image() def __is_form_valid(self): return self.input_nama_acara is not None\