From 597b007333d8ec0d9cfd29e6941fcbe57379108a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 22 May 2023 08:40:47 +0200 Subject: Initial commit --- src/menu.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/menu.py (limited to 'src/menu.py') diff --git a/src/menu.py b/src/menu.py new file mode 100644 index 0000000..319cae1 --- /dev/null +++ b/src/menu.py @@ -0,0 +1,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 -- cgit v1.2.3