def __init__(self, win, x, y, text, index_num, full_name, ok): self.x = x self.y = y self.height = 28 self.text = text self.index_num = index_num self.full_name = full_name self.ok = ok self.button = Button.button_text(win, '', self.x, self.y + 7, 220, self.height, font_color=(255, 255, 255), font_size=16) font_type = pygame.font.Font(shrift, 16) self.font = font_type.render(self.text, True, (0, 0, 0)) self.Theme = 'white'
def music_button(self, win): global num_music, text_x, peremotka_on, Theme self.button = Button.button_text(win, '', self.x, self.y + 7, 220, self.height, font_color=(255, 255, 255), font_size=16) text = str(self.index_num + 1) + ". " + self.text if Theme == 'gradient': self.font_color = (255, 255, 255) if Theme == 'dark': self.font_color = (255, 255, 255) if Theme == 'white': self.font_color = (0, 0, 0) pygame.draw.rect(win, self.font_color, (self.x, self.y + self.height - 2, 220, 1)) try: if Theme != self.Theme or self.font.get_size( )[0] > 220 or self.font == None: self.Theme = Theme font_type = pygame.font.Font(shrift, 16) self.font = font_type.render(text, True, self.font_color) if self.font.get_size()[0] > 220: self.text = self.text[:-1] win.blit(self.font, (self.x, self.y + 7)) except UnicodeError: self.text = str(self.index_num + 1) + ". " text = str(self.index_num + 1) + ". " + self.text self.font = font_type.render(text, True, self.font_color) keys = pygame.key.get_pressed() pos = pygame.mouse.get_pos() mouse_x, mouse_y = pos[0], pos[1] MOUSE_CLICK = pygame.mouse.get_pressed() # print(str(mouse_x) + " " + str(mouse_y)) if mouse_x >= self.x and mouse_x <= self.x + 350 and mouse_y >= 78 and mouse_y <= 378: Dict.roll_mouse_wheel() #indicates the selected tracks for liste in music_class_list: if Button.button_text_click(liste.button) == True: if liste.ok == True: liste.ok = False time.sleep(0.1) elif liste.ok == False: liste.ok = True time.sleep(0.1) for liste in music_class_list: if liste.ok == True: if liste.y + liste.height >= 78 and liste.y + liste.height <= 378: pygame.draw.circle(win, (0, 255, 0), (liste.x - 8, liste.y + 10), 7)