]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler.py
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
13 if getattr(sys
, 'frozen', False):
14 Builder
.load_file(sys
._MEIPASS
+ '/musicsampler.kv')
16 class PlayList(RelativeLayout
):
17 playlist
= ListProperty([])
19 def __init__(self
, **kwargs
):
20 super(PlayList
, self
).__init
__(**kwargs
)
21 Clock
.schedule_interval(self
.update_playlist
, 0.5)
23 def update_playlist(self
, dt
):
24 if self
.parent
is None or 'Mapping' not in self
.parent
.ids
:
27 open_files
= self
.parent
.ids
['Mapping'].open_files
29 for music_file
in open_files
.values():
30 if not music_file
.is_playing():
32 if music_file
.is_paused():
33 self
.playlist
.append(["⏸", music_file
.name
, False])
35 self
.playlist
.append(["⏵", music_file
.name
, True])
38 class ActionList(RelativeLayout
):
39 action_title
= StringProperty("")
40 action_list
= ListProperty([])
42 def update_list(self
, key
, action_number
= 0):
43 self
.action_title
= "actions linked to key {}:".format(key
.key_sym
)
46 action_descriptions
= [action
.description() for action
in key
.actions
]
48 for index
, description
in enumerate(action_descriptions
):
49 if index
< int(action_number
):
51 elif index
+ 0.5 == action_number
:
56 self
.action_list
.append([icon
, description
])
58 class Screen(FloatLayout
):
61 class MusicSamplerApp(App
):
63 Window
.size
= (913, 563)
67 if __name__
== '__main__':
68 MusicSamplerApp().run()