diff options
Diffstat (limited to 'music_sampler.py')
-rw-r--r-- | music_sampler.py | 31 |
1 files changed, 28 insertions, 3 deletions
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 | |||
6 | pygame.mixer.pre_init(frequency = 44100) | 6 | pygame.mixer.pre_init(frequency = 44100) |
7 | pygame.init() | 7 | pygame.init() |
8 | 8 | ||
9 | size = width, height = 1024, 600 | 9 | size = width, height = 913, 563 |
10 | screen = pygame.display.set_mode(size) | 10 | screen = pygame.display.set_mode(size) |
11 | screen.fill((250, 250, 250)) | 11 | screen.fill((229, 228, 226)) |
12 | 12 | ||
13 | draw_lock = helpers.Lock("draw") | 13 | draw_lock = helpers.Lock("draw") |
14 | 14 | ||
15 | mapping = helpers.Mapping(screen, draw_lock) | 15 | mapping = helpers.Mapping(screen, draw_lock) |
16 | channel_number = helpers.parse_config(mapping) | 16 | channel_number, open_files = helpers.parse_config(mapping) |
17 | pygame.mixer.set_num_channels(channel_number) | 17 | pygame.mixer.set_num_channels(channel_number) |
18 | 18 | ||
19 | mapping.draw() | 19 | mapping.draw() |
@@ -49,12 +49,37 @@ while 1: | |||
49 | key = mapping.find_by_key_num(event.key) | 49 | key = mapping.find_by_key_num(event.key) |
50 | if key is not None: | 50 | if key is not None: |
51 | threading.Thread(name = "MSKeyAction", target=key.do_actions).start() | 51 | threading.Thread(name = "MSKeyAction", target=key.do_actions).start() |
52 | threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start() | ||
52 | elif event.type == pygame.MOUSEBUTTONUP: | 53 | elif event.type == pygame.MOUSEBUTTONUP: |
53 | key = mapping.find_by_collidepoint(pygame.mouse.get_pos()) | 54 | key = mapping.find_by_collidepoint(pygame.mouse.get_pos()) |
54 | if key is not None: | 55 | if key is not None: |
55 | threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start() | 56 | threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start() |
56 | 57 | ||
57 | draw_lock.acquire() | 58 | draw_lock.acquire() |
59 | if getattr(sys, 'frozen', False): | ||
60 | icon_police = pygame.font.Font(sys._MEIPASS + "/Symbola.ttf", 19) | ||
61 | police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14) | ||
62 | else: | ||
63 | icon_police = pygame.font.Font("Symbola.ttf", 19) | ||
64 | police = pygame.font.Font("Ubuntu-Regular.ttf", 14) | ||
65 | |||
66 | surface = pygame.Surface((208, 250)).convert() | ||
67 | surface.fill((250, 250, 250)) | ||
68 | offset = 0 | ||
69 | for music_file in open_files.values(): | ||
70 | police.set_bold(False) | ||
71 | if music_file.is_playing(): | ||
72 | icon = icon_police.render("⏵", True, (0,0,0)) | ||
73 | if music_file.is_paused(): | ||
74 | icon = icon_police.render("⏸", True, (0,0,0)) | ||
75 | else: | ||
76 | police.set_bold(True) | ||
77 | text = police.render(music_file.name, True, (0,0,0)) | ||
78 | surface.blit(icon, (0, offset)) | ||
79 | surface.blit(text, (20, offset)) | ||
80 | offset += police.get_linesize() | ||
81 | screen.blit(surface, (700, 308)) | ||
82 | |||
58 | pygame.display.flip() | 83 | pygame.display.flip() |
59 | draw_lock.release() | 84 | draw_lock.release() |
60 | 85 | ||