X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=music_sampler.py;h=714598a37f06a7b3b1a863560cd563fa7f19eb35;hb=63ba5a8dc2aa4ec3e6f203b0ba4db249ecf0b00e;hp=a7faea24921b337e50e688164601276eb8ff36c5;hpb=d8046b94a52262d1453104de2df138a952cb4548;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/music_sampler.py b/music_sampler.py index a7faea2..714598a 100644 --- a/music_sampler.py +++ b/music_sampler.py @@ -1,3 +1,7 @@ +import music_sampler + +music_sampler.parse_args() + import kivy kivy.require("1.9.1") from kivy.app import App @@ -7,13 +11,27 @@ from kivy.properties import ListProperty, StringProperty from kivy.clock import Clock from kivy.core.window import Window from kivy.lang import Builder -from helpers.key import Key -from helpers.mapping import Mapping +from music_sampler.key import Key +from music_sampler.mapping import Mapping + +music_sampler.register_fonts() + +class KeyList(RelativeLayout): + keylist = ListProperty([]) + first_key = StringProperty("") + second_key = StringProperty("") + third_key = StringProperty("") -import sys + def append(self, value): + self.keylist.insert(0, value) -if getattr(sys, 'frozen', False): - Builder.load_file(sys._MEIPASS + '/musicsampler.kv') + def on_keylist(self, instance, new_key_list): + if len(self.keylist) > 0: + self.first_key = self.keylist[0] + if len(self.keylist) > 1: + self.second_key = self.keylist[1] + if len(self.keylist) > 2: + self.third_key = self.keylist[2] class PlayList(RelativeLayout): playlist = ListProperty([]) @@ -29,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( + music_sampler.duration_to_min_sec(music_file.sound_position), + music_sampler.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 @@ -67,4 +87,5 @@ class MusicSamplerApp(App): return Screen() if __name__ == '__main__': + Builder.load_file(music_sampler.path() + "/music_sampler.kv") MusicSamplerApp().run()