X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=music_sampler.py;h=f5df2bf0dd3191ac3438d2352a10f6ce0ef61476;hb=35bde798b6cda13579337b0ec5a803fdd5eab19a;hp=5e61466257fdb631ad8467e6c7bedcb16901ab0c;hpb=65ec4d2a87bfe0dcf1250ec8dc61225d4ed66325;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/music_sampler.py b/music_sampler.py index 5e61466..f5df2bf 100644 --- a/music_sampler.py +++ b/music_sampler.py @@ -1,3 +1,7 @@ +import helpers + +helpers.parse_args() + import kivy kivy.require("1.9.1") from kivy.app import App @@ -9,7 +13,8 @@ from kivy.core.window import Window from kivy.lang import Builder from helpers.key import Key from helpers.mapping import Mapping -import helpers + +helpers.register_fonts() class KeyList(RelativeLayout): keylist = ListProperty([]) @@ -18,7 +23,7 @@ class KeyList(RelativeLayout): third_key = StringProperty("") def append(self, value): - self.keylist = [value] + self.keylist + self.keylist.insert(0, value) def on_keylist(self, instance, new_key_list): if len(self.keylist) > 0: @@ -42,33 +47,35 @@ class PlayList(RelativeLayout): open_files = self.parent.ids['Mapping'].open_files self.playlist = [] for music_file in open_files.values(): - if not music_file.is_playing(): + if not music_file.is_in_use(): continue - if music_file.is_paused(): - self.playlist.append(["⏸", music_file.name, False]) + + text = "{}/{}".format( + helpers.duration_to_min_sec(music_file.sound_position), + helpers.duration_to_min_sec(music_file.sound_duration)) + + if music_file.is_loaded_paused(): + self.playlist.append(["⏸", music_file.name, text, False]) else: - self.playlist.append(["⏵", music_file.name, True]) + self.playlist.append(["⏵", music_file.name, text, True]) class ActionList(RelativeLayout): action_title = StringProperty("") action_list = ListProperty([]) - def update_list(self, key, action_number = 0): + def update_list(self, key, action_descriptions): self.action_title = "actions linked to key {}:".format(key.key_sym) self.action_list = [] - action_descriptions = [action.description() for action in key.actions] - - for index, description in enumerate(action_descriptions): - if index < int(action_number): + for [action, status] in action_descriptions: + if status == "done": icon = "✓" - elif index + 0.5 == action_number: + elif status == "current": icon = "✅" else: icon = " " - - self.action_list.append([icon, description]) + self.action_list.append([icon, action]) class Screen(FloatLayout): pass