]>
Commit | Line | Data |
---|---|---|
d8046b94 IB |
1 | import kivy |
2 | kivy.require("1.9.1") | |
4b2d79ca IB |
3 | from kivy.app import App |
4 | from kivy.uix.floatlayout import FloatLayout | |
5 | from kivy.uix.relativelayout import RelativeLayout | |
6 | from kivy.properties import ListProperty, StringProperty | |
7 | from kivy.clock import Clock | |
8 | from kivy.core.window import Window | |
bb69f62e | 9 | from kivy.lang import Builder |
4b2d79ca IB |
10 | from helpers.key import Key |
11 | from helpers.mapping import Mapping | |
e4846541 | 12 | import helpers |
bb69f62e | 13 | |
4b2d79ca IB |
14 | class 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 |
36 | class 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 |
56 | class Screen(FloatLayout): |
57 | pass | |
189bf90c | 58 | |
4b2d79ca IB |
59 | class MusicSamplerApp(App): |
60 | def build(self): | |
61 | Window.size = (913, 563) | |
9de92b6d | 62 | |
4b2d79ca | 63 | return Screen() |
9de92b6d | 64 | |
4b2d79ca | 65 | if __name__ == '__main__': |
e4846541 | 66 | Builder.load_file(helpers.path() + "/music_sampler.kv") |
4b2d79ca | 67 | MusicSamplerApp().run() |