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