X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=music_sampler.py;h=ff04fd1e42d2d1d62c559cbbd5a9929b353d381b;hb=9de92b6dd2bd906f6a64fce7c90a6aff0dbb27a2;hp=8dbbc28de8e35a9e10e3ba08f08a1a2a96a89c1c;hpb=d479af33afa54fee7c22701c6012a1579ead395f;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/music_sampler.py b/music_sampler.py index 8dbbc28..ff04fd1 100644 --- a/music_sampler.py +++ b/music_sampler.py @@ -6,14 +6,14 @@ import threading pygame.mixer.pre_init(frequency = 44100) pygame.init() -size = width, height = 1024, 600 +size = width, height = 913, 563 screen = pygame.display.set_mode(size) -screen.fill((250, 250, 250)) +screen.fill((229, 228, 226)) draw_lock = helpers.Lock("draw") mapping = helpers.Mapping(screen, draw_lock) -channel_number = helpers.parse_config(mapping) +channel_number, open_files = helpers.parse_config(mapping) pygame.mixer.set_num_channels(channel_number) mapping.draw() @@ -49,12 +49,37 @@ while 1: key = mapping.find_by_key_num(event.key) if key is not None: threading.Thread(name = "MSKeyAction", target=key.do_actions).start() + threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start() elif event.type == pygame.MOUSEBUTTONUP: key = mapping.find_by_collidepoint(pygame.mouse.get_pos()) if key is not None: threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start() draw_lock.acquire() + if getattr(sys, 'frozen', False): + icon_police = pygame.font.Font(sys._MEIPASS + "/Symbola.ttf", 19) + police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14) + else: + icon_police = pygame.font.Font("Symbola.ttf", 19) + police = pygame.font.Font("Ubuntu-Regular.ttf", 14) + + surface = pygame.Surface((208, 250)).convert() + surface.fill((250, 250, 250)) + offset = 0 + for music_file in open_files.values(): + police.set_bold(False) + if music_file.is_playing(): + icon = icon_police.render("⏵", True, (0,0,0)) + if music_file.is_paused(): + icon = icon_police.render("⏸", True, (0,0,0)) + else: + police.set_bold(True) + text = police.render(music_file.name, True, (0,0,0)) + surface.blit(icon, (0, offset)) + surface.blit(text, (20, offset)) + offset += police.get_linesize() + screen.blit(surface, (700, 308)) + pygame.display.flip() draw_lock.release()