]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blame_incremental - music_sampler.py
Make kivy compatible with pyinstaller
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler.py
... / ...
CommitLineData
1from kivy.app import App
2from kivy.uix.floatlayout import FloatLayout
3from kivy.uix.relativelayout import RelativeLayout
4from kivy.properties import ListProperty, StringProperty
5from kivy.clock import Clock
6from kivy.core.window import Window
7from kivy.lang import Builder
8from helpers.key import Key
9from helpers.mapping import Mapping
10
11import sys
12
13if getattr(sys, 'frozen', False):
14 Builder.load_file(sys._MEIPASS + '/musicsampler.kv')
15
16class 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
38class 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
58class Screen(FloatLayout):
59 pass
60
61class MusicSamplerApp(App):
62 def build(self):
63 Window.size = (913, 563)
64
65 return Screen()
66
67if __name__ == '__main__':
68 MusicSamplerApp().run()