def build_menu(self): self.buttons = [] back_button = Button((0, 0, 42, 42), cb=self.go_to_main_menu) back_button.iconFg = pygame.image.load("./resources/images/chevron.png") self.buttons.append(back_button) book_icon_name = "icon.png" #path = "./audiobooks/*/" path = "./" path += self.folder path += "/*/" folders = glob.glob(path) icons = [] for i, folder in enumerate(folders): icons.append(folder + book_icon_name) # 240 Breite: 240 / 3 = 80 > 80 > 10 links + 10 rechts > 60 pixel # 320 - 240 = 80 > links 40 rechts 40 rand screen_margin = 40 x = screen_margin y = 10 for i, folder in enumerate(folders): button = Button((x, y, 80, 80), value=folder, cb=self.on_button_clicked) button.iconFg = pygame.image.load(icons[i]) if x < 200: x += 80 else: x = 40 y += 80 self.buttons.append(button)
def build_menu(self): music_button = Button((60, 80, 80, 80), value="music", cb=self.on_button_clicked) music_button.iconFg = pygame.image.load("./resources/images/note.png") book_button = Button((180, 80, 80, 80), value="audiobooks", cb=self.on_button_clicked) book_button.iconFg = pygame.image.load("./resources/images/book.png") self.buttons.append(music_button) self.buttons.append(book_button)
def init_buttons(self): button = Button((0, 0, 42, 42), cb=self.go_to_menu) button.iconFg = pygame.image.load("./resources/images/chevron.png") self.buttons.append(button) fast_forward = Button((256, 150, 64, 64), cb=self.fast_forward) ff_icon = "./resources/images/next.png" fast_forward.iconFg = pygame.image.load(ff_icon) self.buttons.append(fast_forward) self.play_pause_button = Button((128, 150, 64, 64), cb=self.play_pause) self.play_pause_button.iconFg = self.play_icon self.buttons.append(self.play_pause_button) rewind_button = Button((0, 150, 64, 64), cb=self.rewind) rewind_icon = "./resources/images/previous.png" rewind_button.iconFg = pygame.image.load(rewind_icon) self.buttons.append(rewind_button) # repeat button for music mode self.repeat_button = Button((256, 60, 64, 64), cb=self.repeat) self.repeat_button.iconFg = pygame.image.load(self.repeat_empty_icon)