X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=music_sampler.py;h=d91e150aed51d93d9fa6e7432b2971c3cb05c398;hb=2e4049036ec4d90a9daeff606d821d2ac2d023ce;hp=a7faea24921b337e50e688164601276eb8ff36c5;hpb=d8046b94a52262d1453104de2df138a952cb4548;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/music_sampler.py b/music_sampler.py index a7faea2..d91e150 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 @@ -10,10 +14,22 @@ from kivy.lang import Builder from helpers.key import Key from helpers.mapping import Mapping -import sys +class KeyList(RelativeLayout): + keylist = ListProperty([]) + first_key = StringProperty("") + second_key = StringProperty("") + third_key = StringProperty("") + + 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,12 +45,17 @@ 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_not_stopped(): continue + + text = "{}/{}".format( + helpers.duration_to_min_sec(music_file.sound_position), + helpers.duration_to_min_sec(music_file.sound_duration)) + if music_file.is_paused(): - self.playlist.append(["⏸", music_file.name, False]) + 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): @@ -67,4 +88,5 @@ class MusicSamplerApp(App): return Screen() if __name__ == '__main__': + Builder.load_file(helpers.path() + "/music_sampler.kv") MusicSamplerApp().run()