]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler.py
81b96c4c29d32ea45498109e28548e2d40e19602
3 from kivy
.app
import App
4 from kivy
.uix
.floatlayout
import FloatLayout
5 from kivy
.uix
.relativelayout
import RelativeLayout
6 from kivy
.properties
import ListProperty
, StringProperty
7 from kivy
.clock
import Clock
8 from kivy
.core
.window
import Window
9 from kivy
.lang
import Builder
10 from helpers
.key
import Key
11 from helpers
.mapping
import Mapping
14 class PlayList(RelativeLayout
):
15 playlist
= ListProperty([])
17 def __init__(self
, **kwargs
):
18 super(PlayList
, self
).__init
__(**kwargs
)
19 Clock
.schedule_interval(self
.update_playlist
, 0.5)
21 def update_playlist(self
, dt
):
22 if self
.parent
is None or 'Mapping' not in self
.parent
.ids
:
25 open_files
= self
.parent
.ids
['Mapping'].open_files
27 for music_file
in open_files
.values():
28 if not music_file
.is_playing():
30 if music_file
.is_paused():
31 self
.playlist
.append(["⏸", music_file
.name
, False])
33 self
.playlist
.append(["⏵", music_file
.name
, True])
36 class ActionList(RelativeLayout
):
37 action_title
= StringProperty("")
38 action_list
= ListProperty([])
40 def update_list(self
, key
, action_number
= 0):
41 self
.action_title
= "actions linked to key {}:".format(key
.key_sym
)
44 action_descriptions
= [action
.description() for action
in key
.actions
]
46 for index
, description
in enumerate(action_descriptions
):
47 if index
< int(action_number
):
49 elif index
+ 0.5 == action_number
:
54 self
.action_list
.append([icon
, description
])
56 class Screen(FloatLayout
):
59 class MusicSamplerApp(App
):
61 Window
.size
= (913, 563)
65 if __name__
== '__main__':
66 Builder
.load_file(helpers
.path() + "/music_sampler.kv")
67 MusicSamplerApp().run()