]>
Commit | Line | Data |
---|---|---|
1 | import kivy | |
2 | kivy.require("1.9.1") | |
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 | |
9 | from kivy.lang import Builder | |
10 | from helpers.key import Key | |
11 | from helpers.mapping import Mapping | |
12 | import helpers | |
13 | ||
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]) | |
34 | ||
35 | ||
36 | class ActionList(RelativeLayout): | |
37 | action_title = StringProperty("") | |
38 | action_list = ListProperty([]) | |
39 | ||
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 = [] | |
43 | ||
44 | action_descriptions = [action.description() for action in key.actions] | |
45 | ||
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 = " " | |
53 | ||
54 | self.action_list.append([icon, description]) | |
55 | ||
56 | class Screen(FloatLayout): | |
57 | pass | |
58 | ||
59 | class MusicSamplerApp(App): | |
60 | def build(self): | |
61 | Window.size = (913, 563) | |
62 | ||
63 | return Screen() | |
64 | ||
65 | if __name__ == '__main__': | |
66 | Builder.load_file(helpers.path() + "/music_sampler.kv") | |
67 | MusicSamplerApp().run() |