From 30d8796f2a29a7e1baad56106eb4ffc2ef0c632c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 27 Jun 2016 13:19:00 +0200 Subject: Add indicator of whether all keys are ready --- helpers/mapping.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'helpers') diff --git a/helpers/mapping.py b/helpers/mapping.py index 28f4acd..e800778 100644 --- a/helpers/mapping.py +++ b/helpers/mapping.py @@ -1,6 +1,7 @@ from kivy.uix.relativelayout import RelativeLayout -from kivy.properties import NumericProperty +from kivy.properties import NumericProperty, ListProperty from kivy.core.window import Window +from kivy.clock import Clock import threading import pygame @@ -12,6 +13,7 @@ from .music_file import * class Mapping(RelativeLayout): expected_keys = NumericProperty(0) + ready_color = ListProperty([1, 165/255, 0, 1]) def __init__(self, **kwargs): self.key_config, self.channel_number, self.open_files = self.parse_config() @@ -19,6 +21,7 @@ class Mapping(RelativeLayout): self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self.running = [] + Clock.schedule_interval(self.not_all_keys_ready, 1) pygame.mixer.init(frequency = 44100) @@ -57,6 +60,15 @@ class Mapping(RelativeLayout): return key return None + def not_all_keys_ready(self, dt): + for key in self.children: + if not type(key).__name__ == "Key": + continue + if not key.is_key_ready: + return True + self.ready_color = [0, 1, 0, 1] + return False + def stop_all_running(self): self.running = [] -- cgit v1.2.3