blob: 319cae1a3cda8dceba0d20520b6c95afc11dd312 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import skeleton
def build_application(apps):
enabled_apps = [app for app in apps if app.visible]
max_l = min(12, len(enabled_apps))
configuration = skeleton.Configuration("Application menu")
for index in range(max_l):
if enabled_apps[index] is None:
break
# I use a lambda function here, the index is stored in a closure
# otherwise the value is erased and only keep the last iteration
# index
callback = lambda n:lambda macropad, key, pressed:enabled_apps[n]
configuration.registerKey(
index,
enabled_apps[index].title,
callback(index),
None
)
return configuration
|