X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Fkey.py;h=fe82d5bea396a9a4d31b412a483f80b29fb2d810;hb=a24c34bc1458c4b0962773d804fac4d325632ee8;hp=f49b3ec6a6b9ebc070d45d4803038c61d1715c06;hpb=f029e879b326c3b3dce3428561a280fa52b9f04c;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/helpers/key.py b/helpers/key.py index f49b3ec..fe82d5b 100644 --- a/helpers/key.py +++ b/helpers/key.py @@ -4,6 +4,7 @@ from kivy.clock import Clock from kivy.uix.behaviors import ButtonBehavior from .action import * +from . import debug_print import time class Key(ButtonBehavior, Widget): @@ -79,18 +80,22 @@ class Key(ButtonBehavior, Widget): def add_action(self, action_name, **arguments): self.actions.append(Action(action_name, self, **arguments)) + def interrupt_action(self): + self.current_action.interrupt() + def do_actions(self): if not self.enabled: return None - print("running actions for {}".format(self.key_sym)) + self.parent.parent.ids['KeyList'].append(self.key_sym) + debug_print("running actions for {}".format(self.key_sym)) start_time = time.time() self.parent.start_running(self, start_time) action_number = 0 - for action in self.actions: + for self.current_action in self.actions: if self.parent.keep_running(self, start_time): self.list_actions(action_number = action_number + 0.5) - action.run() + self.current_action.run() action_number += 1 self.list_actions(action_number = action_number)