]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Add exit key
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 25 Jun 2016 23:20:37 +0000 (01:20 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 25 Jun 2016 23:20:37 +0000 (01:20 +0200)
helpers/mapping.py

index 4a1cd980e67546395267044206e0ca415090afe1..66d860d9bcf58b7ca747e4102a4b37f1838abebc 100644 (file)
@@ -5,6 +5,7 @@ from kivy.core.window import Window
 import threading
 import pygame
 import yaml
+import sys
 
 from .lock import *
 from .music_file import *
@@ -29,8 +30,16 @@ class Mapping(RelativeLayout):
 
     def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
         key = self.find_by_key_code(keycode)
-        if key is not None:
+        if len(modifiers) == 0 and key is not None:
             threading.Thread(name = "MSKeyAction", target=key.do_actions).start()
+        elif 'ctrl' in modifiers and (keycode[0] == 113 or keycode[0] == '99'):
+            for thread in threading.enumerate():
+                if thread.getName()[0:2] != "MS":
+                    continue
+                thread.join()
+
+            pygame.quit()
+            sys.exit()
         return True
 
     def find_by_key_code(self, key_code):