]>
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 | ||
13 | import sys | |
14 | ||
15 | if getattr(sys, 'frozen', False): | |
16 | Builder.load_file(sys._MEIPASS + '/musicsampler.kv') | |
17 | ||
18 | class PlayList(RelativeLayout): | |
19 | playlist = ListProperty([]) | |
20 | ||
21 | def __init__(self, **kwargs): | |
22 | super(PlayList, self).__init__(**kwargs) | |
23 | Clock.schedule_interval(self.update_playlist, 0.5) | |
24 | ||
25 | def update_playlist(self, dt): | |
26 | if self.parent is None or 'Mapping' not in self.parent.ids: | |
27 | return True | |
28 | ||
29 | open_files = self.parent.ids['Mapping'].open_files | |
30 | self.playlist = [] | |
31 | for music_file in open_files.values(): | |
32 | if not music_file.is_playing(): | |
33 | continue | |
34 | if music_file.is_paused(): | |
35 | self.playlist.append(["⏸", music_file.name, False]) | |
36 | else: | |
37 | self.playlist.append(["⏵", music_file.name, True]) | |
38 | ||
39 | ||
40 | class ActionList(RelativeLayout): | |
41 | action_title = StringProperty("") | |
42 | action_list = ListProperty([]) | |
43 | ||
44 | def update_list(self, key, action_number = 0): | |
45 | self.action_title = "actions linked to key {}:".format(key.key_sym) | |
46 | self.action_list = [] | |
47 | ||
48 | action_descriptions = [action.description() for action in key.actions] | |
49 | ||
50 | for index, description in enumerate(action_descriptions): | |
51 | if index < int(action_number): | |
52 | icon = "✓" | |
53 | elif index + 0.5 == action_number: | |
54 | icon = "✅" | |
55 | else: | |
56 | icon = " " | |
57 | ||
58 | self.action_list.append([icon, description]) | |
59 | ||
60 | class Screen(FloatLayout): | |
61 | pass | |
62 | ||
63 | class MusicSamplerApp(App): | |
64 | def build(self): | |
65 | Window.size = (913, 563) | |
66 | ||
67 | return Screen() | |
68 | ||
69 | if __name__ == '__main__': | |
70 | MusicSamplerApp().run() |