]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler/app.py
Use labels stacking to build playlist
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler / app.py
1 from .helpers import parse_args, register_fonts, path
2
3 parse_args()
4
5 import kivy
6 kivy.require("1.9.1")
7 from kivy.app import App
8 from kivy.uix.floatlayout import FloatLayout
9 from kivy.uix.stacklayout import StackLayout
10 from kivy.uix.relativelayout import RelativeLayout
11 from kivy.properties import ListProperty, StringProperty
12 from kivy.core.window import Window
13 from kivy.lang import Builder
14 from .key import Key
15 from .mapping import Mapping
16
17 register_fonts()
18
19 from .app_blocks.playlist import *
20
21 class KeyList(RelativeLayout):
22 keylist = ListProperty([])
23 first_key = StringProperty("")
24 second_key = StringProperty("")
25 third_key = StringProperty("")
26
27 def append(self, value):
28 self.keylist.insert(0, value)
29
30 def on_keylist(self, instance, new_key_list):
31 if len(self.keylist) > 0:
32 self.first_key = self.keylist[0]
33 if len(self.keylist) > 1:
34 self.second_key = self.keylist[1]
35 if len(self.keylist) > 2:
36 self.third_key = self.keylist[2]
37
38 class ActionList(RelativeLayout):
39 action_title = StringProperty("")
40 action_list = ListProperty([])
41
42 def update_list(self, key, action_descriptions):
43 self.action_title = "actions linked to key {}:".format(key.key_sym)
44 self.action_list = []
45
46 for [action, status] in action_descriptions:
47 if status == "done":
48 icon = "✓"
49 elif status == "current":
50 icon = "✅"
51 else:
52 icon = " "
53 self.action_list.append([icon, action])
54
55 class Screen(FloatLayout):
56 pass
57
58 class MusicSamplerApp(App):
59 def build(self):
60 Window.size = (913, 563)
61
62 return Screen()
63
64 def main():
65 Builder.load_file(path() + "/music_sampler.kv")
66 MusicSamplerApp().run()