]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blame - music_sampler.py
Move kv file
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler.py
CommitLineData
d8046b94
IB
1import kivy
2kivy.require("1.9.1")
4b2d79ca
IB
3from kivy.app import App
4from kivy.uix.floatlayout import FloatLayout
5from kivy.uix.relativelayout import RelativeLayout
6from kivy.properties import ListProperty, StringProperty
7from kivy.clock import Clock
8from kivy.core.window import Window
bb69f62e 9from kivy.lang import Builder
4b2d79ca
IB
10from helpers.key import Key
11from helpers.mapping import Mapping
e4846541 12import helpers
bb69f62e 13
4b2d79ca
IB
14class PlayList(RelativeLayout):
15 playlist = ListProperty([])
16
17 def __init__(self, **kwargs):
18 super(PlayList, self).__init__(**kwargs)
19 Clock.schedule_interval(self.update_playlist, 0.5)
20
21 def update_playlist(self, dt):
22 if self.parent is None or 'Mapping' not in self.parent.ids:
23 return True
24
25 open_files = self.parent.ids['Mapping'].open_files
26 self.playlist = []
27 for music_file in open_files.values():
28 if not music_file.is_playing():
29 continue
30 if music_file.is_paused():
31 self.playlist.append(["⏸", music_file.name, False])
32 else:
33 self.playlist.append(["⏵", music_file.name, True])
189bf90c 34
189bf90c 35
4b2d79ca
IB
36class ActionList(RelativeLayout):
37 action_title = StringProperty("")
38 action_list = ListProperty([])
189bf90c 39
4b2d79ca
IB
40 def update_list(self, key, action_number = 0):
41 self.action_title = "actions linked to key {}:".format(key.key_sym)
42 self.action_list = []
189bf90c 43
4b2d79ca 44 action_descriptions = [action.description() for action in key.actions]
e7f8dab4 45
4b2d79ca
IB
46 for index, description in enumerate(action_descriptions):
47 if index < int(action_number):
48 icon = "✓"
49 elif index + 0.5 == action_number:
50 icon = "✅"
51 else:
52 icon = " "
be27763f 53
4b2d79ca 54 self.action_list.append([icon, description])
189bf90c 55
4b2d79ca
IB
56class Screen(FloatLayout):
57 pass
189bf90c 58
4b2d79ca
IB
59class MusicSamplerApp(App):
60 def build(self):
61 Window.size = (913, 563)
9de92b6d 62
4b2d79ca 63 return Screen()
9de92b6d 64
4b2d79ca 65if __name__ == '__main__':
e4846541 66 Builder.load_file(helpers.path() + "/music_sampler.kv")
4b2d79ca 67 MusicSamplerApp().run()