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