]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - helpers/key.py
enhancing locks
[perso/Immae/Projets/Python/MusicSampler.git] / helpers / key.py
index 2e4a313b39f28abb324cb1689e433621b95d1c3d..6997e702d75a78040e391e77e225a02a40b08d76 100644 (file)
@@ -112,9 +112,32 @@ class Key:
 
         self.mapping.finished_running(self, start_time)
 
-    def list_actions(self, surface):
-        # FIXME: Todo
-        print("bouh", self.key_sym)
-        surface.fill((255, 0, 0))
+    def list_actions(self, screen):
+        action_descriptions = [action.description() for action in self.actions]
+        print("actions linked to key {}:".format(self.key_sym))
+        print("\t" + "\n\t".join(action_descriptions))
+        self.draw_lock.acquire()
+        surface = pygame.Surface((800, 250)).convert()
+        surface.fill((250, 250, 250))
+        if getattr(sys, 'frozen', False):
+            police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14)
+        else:
+            police = pygame.font.Font("Ubuntu-Regular.ttf", 14)
+
+        offset = 0
+        police.set_bold(True)
+        text = police.render("actions linked to key {}:".format(self.key_sym), True, (0,0,0))
+        surface.blit(text, (0, offset))
+        offset += police.get_linesize()
+
+        police.set_bold(False)
+        for description in action_descriptions:
+            text = police.render(description, True, (0,0,0))
+            surface.blit(text, (0, offset))
+            offset += police.get_linesize()
+
+        screen.blit(surface, (10, 330))
+        pygame.display.flip()
+        self.draw_lock.release()