]>
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
8 from helpers
.key
import Key
9 from helpers
.mapping
import Mapping
11 class PlayList(RelativeLayout
):
12 playlist
= ListProperty([])
14 def __init__(self
, **kwargs
):
15 super(PlayList
, self
).__init
__(**kwargs
)
16 Clock
.schedule_interval(self
.update_playlist
, 0.5)
18 def update_playlist(self
, dt
):
19 if self
.parent
is None or 'Mapping' not in self
.parent
.ids
:
22 open_files
= self
.parent
.ids
['Mapping'].open_files
24 for music_file
in open_files
.values():
25 if not music_file
.is_playing():
27 if music_file
.is_paused():
28 self
.playlist
.append(["⏸", music_file
.name
, False])
30 self
.playlist
.append(["⏵", music_file
.name
, True])
33 class ActionList(RelativeLayout
):
34 action_title
= StringProperty("")
35 action_list
= ListProperty([])
37 def update_list(self
, key
, action_number
= 0):
38 self
.action_title
= "actions linked to key {}:".format(key
.key_sym
)
41 action_descriptions
= [action
.description() for action
in key
.actions
]
43 for index
, description
in enumerate(action_descriptions
):
44 if index
< int(action_number
):
46 elif index
+ 0.5 == action_number
:
51 self
.action_list
.append([icon
, description
])
53 class Screen(FloatLayout
):
56 class MusicSamplerApp(App
):
58 Window
.size
= (913, 563)
62 if __name__
== '__main__':
63 MusicSamplerApp().run()