omnipython-applibs 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- appkit/__init__.py +52 -0
- appkit/__init__.pyi +17 -0
- appkit/data.py +149 -0
- appkit/data.pyi +25 -0
- appkit/foreground.py +357 -0
- appkit/foreground.pyi +45 -0
- appkit/home.py +19 -0
- appkit/home.pyi +8 -0
- appkit/hover.py +59 -0
- appkit/hover.pyi +13 -0
- appkit/index.py +199 -0
- appkit/index.pyi +30 -0
- appkit/launcher.py +1075 -0
- appkit/launcher.pyi +96 -0
- appkit/manifest.py +75 -0
- appkit/manifest.pyi +8 -0
- appkit/net.py +167 -0
- appkit/net.pyi +34 -0
- appkit/places.py +202 -0
- appkit/places.pyi +39 -0
- appkit/py.typed +0 -0
- appkit/scope.py +636 -0
- appkit/scope.pyi +110 -0
- appkit/shell.py +121 -0
- appkit/shell.pyi +32 -0
- appkit/worker.py +409 -0
- appkit/worker.pyi +83 -0
- controlkit/__init__.py +19 -0
- controlkit/__init__.pyi +10 -0
- controlkit/_draw.py +88 -0
- controlkit/_safe.py +29 -0
- controlkit/dotmatrix.py +101 -0
- controlkit/dotmatrix.pyi +23 -0
- controlkit/encoder.py +297 -0
- controlkit/encoder.pyi +55 -0
- controlkit/font5x7.py +22 -0
- controlkit/font5x7.pyi +11 -0
- controlkit/lamp_button.py +92 -0
- controlkit/lamp_button.pyi +40 -0
- controlkit/meter.py +86 -0
- controlkit/meter.pyi +30 -0
- controlkit/mock.py +116 -0
- controlkit/mock.pyi +35 -0
- controlkit/pad_grid.py +113 -0
- controlkit/pad_grid.pyi +41 -0
- controlkit/py.typed +0 -0
- controlkit/slider.py +185 -0
- controlkit/slider.pyi +49 -0
- controlkit/sprites.py +279 -0
- controlkit/sprites.pyi +22 -0
- controlkit/theme.py +120 -0
- controlkit/theme.pyi +15 -0
- deskkit/__init__.py +74 -0
- deskkit/__init__.pyi +18 -0
- deskkit/forecast.py +261 -0
- deskkit/forecast.pyi +40 -0
- deskkit/localtime.py +215 -0
- deskkit/localtime.pyi +33 -0
- deskkit/py.typed +0 -0
- deskkit/shell.py +113 -0
- deskkit/shell.pyi +33 -0
- omnipython_applibs-0.1.2.dist-info/METADATA +90 -0
- omnipython_applibs-0.1.2.dist-info/RECORD +143 -0
- omnipython_applibs-0.1.2.dist-info/WHEEL +5 -0
- omnipython_applibs-0.1.2.dist-info/licenses/LICENSE +21 -0
- omnipython_applibs-0.1.2.dist-info/top_level.txt +9 -0
- programkit/__init__.py +27 -0
- programkit/__init__.pyi +8 -0
- programkit/board.py +56 -0
- programkit/board.pyi +20 -0
- programkit/press.py +63 -0
- programkit/press.pyi +17 -0
- programkit/py.typed +0 -0
- programkit/rows.py +149 -0
- programkit/rows.pyi +34 -0
- sayso/__init__.py +109 -0
- sayso/__init__.pyi +124 -0
- sayso/auth.py +811 -0
- sayso/auth.pyi +102 -0
- sayso/client.py +1286 -0
- sayso/client.pyi +138 -0
- sayso/keepalive.py +371 -0
- sayso/keepalive.pyi +53 -0
- sayso/local.py +85 -0
- sayso/local.pyi +28 -0
- sayso/object_specs.py +706 -0
- sayso/object_specs.pyi +8 -0
- sayso/objects.py +411 -0
- sayso/objects.pyi +854 -0
- sayso/py.typed +0 -0
- sayso/schema_coverage.py +210 -0
- sayso/schema_coverage.pyi +13 -0
- sayso/transport.py +426 -0
- sayso/transport.pyi +47 -0
- songmodel/__init__.py +30 -0
- songmodel/__init__.pyi +9 -0
- songmodel/link.py +189 -0
- songmodel/link.pyi +53 -0
- songmodel/model.py +238 -0
- songmodel/model.pyi +40 -0
- songmodel/page.html +225 -0
- songmodel/page_data.py +236 -0
- songmodel/page_data.pyi +6 -0
- songmodel/py.typed +0 -0
- soundmodule/__init__.py +7 -0
- soundmodule/__init__.pyi +6 -0
- soundmodule/engine.py +1001 -0
- soundmodule/engine.pyi +196 -0
- soundmodule/names.py +298 -0
- soundmodule/names.pyi +30 -0
- soundmodule/pipes.py +105 -0
- soundmodule/pipes.pyi +31 -0
- soundmodule/py.typed +0 -0
- soundmodule/run.py +249 -0
- soundmodule/run.pyi +49 -0
- spectrum/__init__.py +72 -0
- spectrum/__init__.pyi +30 -0
- spectrum/analyzer.py +231 -0
- spectrum/analyzer.pyi +67 -0
- spectrum/fake_music.py +201 -0
- spectrum/fake_music.pyi +36 -0
- spectrum/pump_levels.py +126 -0
- spectrum/pump_levels.pyi +46 -0
- spectrum/py.typed +0 -0
- spectrum/spectrum_view.py +403 -0
- spectrum/spectrum_view.pyi +80 -0
- touchkit/__init__.py +4 -0
- touchkit/__init__.pyi +4 -0
- touchkit/cam.py +146 -0
- touchkit/cam.pyi +35 -0
- touchkit/clock.py +18 -0
- touchkit/clock.pyi +6 -0
- touchkit/ecp.py +134 -0
- touchkit/ecp.pyi +28 -0
- touchkit/net.py +347 -0
- touchkit/net.pyi +27 -0
- touchkit/py.typed +0 -0
- touchkit/settings.py +85 -0
- touchkit/settings.pyi +17 -0
- touchkit/shell.py +268 -0
- touchkit/shell.pyi +42 -0
- touchkit/ui.py +167 -0
- touchkit/ui.pyi +53 -0
appkit/hover.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Hover styles for LVGL apps: a control lights up under the mouse.
|
|
5
|
+
|
|
6
|
+
LVGL marks the widget under the pointer as hovered, but its default theme
|
|
7
|
+
draws nothing for that. `apply` layers one outline on top of the display's
|
|
8
|
+
theme, for buttons, list rows, tabs, sliders and switches, so every app gets
|
|
9
|
+
the same look without styling its own. An outline works on any colour an app
|
|
10
|
+
gives a control. `Shell` calls it once, after the board's own theme is set.
|
|
11
|
+
|
|
12
|
+
Hover follows the mouse only. A finger never hovers: the display driver moves
|
|
13
|
+
the pointer off the screen when a touch lifts.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import lvgl as lv
|
|
17
|
+
|
|
18
|
+
#: How wide the outline is, in pixels, and how strongly it shows.
|
|
19
|
+
WIDTH = 2
|
|
20
|
+
OPACITY = 200
|
|
21
|
+
|
|
22
|
+
_style = None
|
|
23
|
+
_applied = [] # [True] once the theme is layered, so a second call is a no-op
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _hover_style():
|
|
27
|
+
global _style
|
|
28
|
+
if _style is None:
|
|
29
|
+
_style = lv.style_t()
|
|
30
|
+
_style.init()
|
|
31
|
+
_style.set_outline_width(WIDTH)
|
|
32
|
+
_style.set_outline_color(lv.color_white())
|
|
33
|
+
_style.set_outline_opa(OPACITY)
|
|
34
|
+
_style.set_outline_pad(-1) # half inside: a clipping parent still shows the ring
|
|
35
|
+
return _style
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _apply_cb(theme, obj):
|
|
39
|
+
style = _hover_style()
|
|
40
|
+
if obj.has_class(lv.button_class) or obj.has_class(lv.list_button_class):
|
|
41
|
+
obj.add_style(style, lv.STATE.HOVERED)
|
|
42
|
+
elif obj.has_class(lv.slider_class) or obj.has_class(lv.switch_class):
|
|
43
|
+
obj.add_style(style, lv.PART.KNOB | lv.STATE.HOVERED)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def apply(disp=None):
|
|
47
|
+
"""Add hover styles to *disp*'s theme (the default display's if omitted).
|
|
48
|
+
|
|
49
|
+
Call it after the board's own theme is set: it wraps whatever theme is
|
|
50
|
+
there. Widgets made afterwards get the styles.
|
|
51
|
+
"""
|
|
52
|
+
disp = disp or lv.display_get_default()
|
|
53
|
+
if _applied or disp is None or disp.get_theme() is None:
|
|
54
|
+
return
|
|
55
|
+
theme = lv.theme_create()
|
|
56
|
+
theme.set_parent(disp.get_theme())
|
|
57
|
+
theme.set_apply_cb(_apply_cb)
|
|
58
|
+
disp.set_theme(theme)
|
|
59
|
+
_applied.append(True)
|
appkit/hover.pyi
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Hover styles for LVGL apps: a control lights up under the mouse."""
|
|
5
|
+
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
#: How wide the outline is, in pixels, and how strongly it shows.
|
|
9
|
+
WIDTH: int
|
|
10
|
+
OPACITY: int
|
|
11
|
+
|
|
12
|
+
def apply(disp: Any = None) -> None:
|
|
13
|
+
"""Add hover styles to `disp`'s theme (the default display's if omitted)."""
|
appkit/index.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Build the app index a frozen build reads in place of the apps folder.
|
|
5
|
+
|
|
6
|
+
MicroPython can freeze ``.py`` files but not an ``app.json``, so at build
|
|
7
|
+
time this turns every ``<apps>/<app>/app.json`` into one module,
|
|
8
|
+
``_appkit_apps``, frozen with the apps in the package ``apps``. ``Launcher.scan("apps")`` reads it
|
|
9
|
+
when the folder isn't there.
|
|
10
|
+
|
|
11
|
+
From a MicroPython ``manifest.py``, include appkit's own manifest with the
|
|
12
|
+
apps folder, as an absolute path::
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
include("/path/to/appkit", apps=os.path.abspath("apps"))
|
|
16
|
+
|
|
17
|
+
or call `freeze_apps` yourself. From a shell::
|
|
18
|
+
|
|
19
|
+
python -m appkit.index apps -o build/_appkit_apps.py
|
|
20
|
+
|
|
21
|
+
This module runs on CPython at build time and imports nothing from appkit,
|
|
22
|
+
so it can be loaded on its own: ``python lib/appkit/index.py apps``.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
import json
|
|
26
|
+
import os
|
|
27
|
+
import sys
|
|
28
|
+
|
|
29
|
+
MODULE = "_appkit_apps"
|
|
30
|
+
#: The package a frozen build's apps are in, whatever their folder's name.
|
|
31
|
+
PACKAGE = "apps"
|
|
32
|
+
#: An apps folder's ``__init__.py``, when it has none of its own.
|
|
33
|
+
INIT_TEXT = "# The apps folder is a package: appkit imports each app in it as %s.<app>.\n" % PACKAGE
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _tile_icons():
|
|
37
|
+
"""The icon names a Home tile can show: iconkit's 48 px set."""
|
|
38
|
+
try:
|
|
39
|
+
import iconkit
|
|
40
|
+
except ImportError as exc:
|
|
41
|
+
raise ImportError(
|
|
42
|
+
"appkit's index needs iconkit to check app icons: pip install omnipython-iconkit, "
|
|
43
|
+
"or put packages/iconkit/lib from the omnipython repository on the import path"
|
|
44
|
+
) from exc
|
|
45
|
+
return iconkit.names(48)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def check_icon(entry, info, path):
|
|
49
|
+
"""Raise ``ValueError`` when the app *entry* (``info`` is its app.json, read from *path*)
|
|
50
|
+
shows a tile and has no ``"icon"`` in iconkit's 48 px set. An app with ``"tile": false`` needs none."""
|
|
51
|
+
if info.get("tile", True) is False:
|
|
52
|
+
return
|
|
53
|
+
icon = info.get("icon")
|
|
54
|
+
if icon is None:
|
|
55
|
+
raise ValueError(
|
|
56
|
+
'%s: app %r has no "icon". Every app with a tile needs one: add "icon": "<Material icon name>" '
|
|
57
|
+
'to its app.json, taken from iconkit.names(48), or set "tile": false.' % (path, entry)
|
|
58
|
+
)
|
|
59
|
+
names = _tile_icons()
|
|
60
|
+
if icon not in names:
|
|
61
|
+
raise ValueError(
|
|
62
|
+
'%s: app %r names icon %r, which iconkit has no 48 px tile icon for. Pick one of: %s. '
|
|
63
|
+
"(Build more with iconkit's make_icons.py and register them with iconkit.add().)"
|
|
64
|
+
% (path, entry, icon, ", ".join(names))
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def collect(folder):
|
|
69
|
+
"""``[(entry, app.json contents), ...]`` for every app in *folder*, sorted.
|
|
70
|
+
|
|
71
|
+
Raises:
|
|
72
|
+
ValueError: An app.json isn't a JSON object, or an app with a tile has no
|
|
73
|
+
``"icon"`` or one that isn't in iconkit's 48 px set.
|
|
74
|
+
"""
|
|
75
|
+
apps = []
|
|
76
|
+
for entry in sorted(os.listdir(folder)):
|
|
77
|
+
path = os.path.join(folder, entry, "app.json")
|
|
78
|
+
if not os.path.isfile(path):
|
|
79
|
+
continue
|
|
80
|
+
with open(path) as f:
|
|
81
|
+
try:
|
|
82
|
+
info = json.load(f)
|
|
83
|
+
except ValueError as exc:
|
|
84
|
+
raise ValueError("%s: %s" % (path, exc))
|
|
85
|
+
if not isinstance(info, dict):
|
|
86
|
+
raise ValueError("%s: not a JSON object" % (path,))
|
|
87
|
+
check_icon(entry, info, path)
|
|
88
|
+
apps.append((entry, info))
|
|
89
|
+
return apps
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def render(apps, source=None):
|
|
93
|
+
"""The ``_appkit_apps`` module's text for *apps* (see `collect`)."""
|
|
94
|
+
lines = [
|
|
95
|
+
"# Generated by appkit.index%s: do not edit." % (" from " + source if source else ""),
|
|
96
|
+
"# The package the apps are frozen in, and (entry folder, app.json",
|
|
97
|
+
"# contents) for each app, in order.",
|
|
98
|
+
"PACKAGE = %r" % (PACKAGE,),
|
|
99
|
+
"APPS = (",
|
|
100
|
+
]
|
|
101
|
+
for entry, info in apps:
|
|
102
|
+
lines.append(" (%r, %r)," % (entry, info))
|
|
103
|
+
lines.append(")")
|
|
104
|
+
return "\n".join(lines) + "\n"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def write(folder, out=None):
|
|
108
|
+
"""Write the index of *folder* to *out* (a file, or a folder to put
|
|
109
|
+
``_appkit_apps.py`` in; default: the current folder). Returns the file's path."""
|
|
110
|
+
apps = collect(folder)
|
|
111
|
+
if out is None:
|
|
112
|
+
out = "."
|
|
113
|
+
if os.path.isdir(out):
|
|
114
|
+
out = os.path.join(out, MODULE + ".py")
|
|
115
|
+
with open(out, "w", encoding="utf-8") as f:
|
|
116
|
+
f.write(render(apps, os.path.basename(os.path.normpath(folder)) + "/*/app.json"))
|
|
117
|
+
return out
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def freeze_apps(folder, module, package, out_dir=None):
|
|
121
|
+
"""From a MicroPython manifest: freeze every app in *folder* and its index.
|
|
122
|
+
|
|
123
|
+
*module* and *package* are the manifest's own functions. The apps are
|
|
124
|
+
frozen in the package ``apps`` (``apps.<app>``, as ``scan()`` imports
|
|
125
|
+
them), whatever their folder is called: they're copied to
|
|
126
|
+
``<out_dir>/apps`` first, with an ``__init__.py`` made for the package
|
|
127
|
+
when the folder has none. A script entry's module is frozen on its own
|
|
128
|
+
when it is a file in the app's folder (``<app>/<script>.py``);
|
|
129
|
+
otherwise the build must freeze it elsewhere, like any library. The
|
|
130
|
+
index is written to *out_dir* (default: a new temporary folder) and
|
|
131
|
+
frozen as ``_appkit_apps``.
|
|
132
|
+
"""
|
|
133
|
+
import shutil
|
|
134
|
+
import tempfile
|
|
135
|
+
|
|
136
|
+
folder = os.path.abspath(folder)
|
|
137
|
+
if out_dir is None:
|
|
138
|
+
out_dir = tempfile.mkdtemp(prefix="appkit-index-")
|
|
139
|
+
elif not os.path.isdir(out_dir):
|
|
140
|
+
os.makedirs(out_dir)
|
|
141
|
+
write(folder, out_dir)
|
|
142
|
+
module(MODULE + ".py", base_path=out_dir)
|
|
143
|
+
stage = os.path.join(out_dir, PACKAGE)
|
|
144
|
+
if os.path.isdir(stage):
|
|
145
|
+
shutil.rmtree(stage)
|
|
146
|
+
os.makedirs(stage)
|
|
147
|
+
init = os.path.join(folder, "__init__.py")
|
|
148
|
+
if os.path.isfile(init):
|
|
149
|
+
shutil.copy2(init, stage)
|
|
150
|
+
else:
|
|
151
|
+
with open(os.path.join(stage, "__init__.py"), "w", encoding="utf-8") as f:
|
|
152
|
+
f.write(INIT_TEXT)
|
|
153
|
+
module(PACKAGE + "/__init__.py", base_path=out_dir)
|
|
154
|
+
|
|
155
|
+
def not_python(where, names):
|
|
156
|
+
return [
|
|
157
|
+
n
|
|
158
|
+
for n in names
|
|
159
|
+
if n.startswith(".")
|
|
160
|
+
or n == "__pycache__"
|
|
161
|
+
or (not n.endswith(".py") and not os.path.isdir(os.path.join(where, n)))
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
for entry, info in collect(folder):
|
|
165
|
+
where = os.path.join(folder, entry)
|
|
166
|
+
script = info.get("script")
|
|
167
|
+
if script:
|
|
168
|
+
if os.path.isfile(os.path.join(where, script + ".py")):
|
|
169
|
+
module(script + ".py", base_path=where)
|
|
170
|
+
elif os.path.isfile(os.path.join(where, "__init__.py")):
|
|
171
|
+
shutil.copytree(where, os.path.join(stage, entry), ignore=not_python)
|
|
172
|
+
package(PACKAGE + "/" + entry, base_path=out_dir)
|
|
173
|
+
else:
|
|
174
|
+
raise ValueError("%s has an app.json but no __init__.py" % (where,))
|
|
175
|
+
return out_dir
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def main(argv=None):
|
|
179
|
+
"""``python -m appkit.index APPS [-o OUT]``: write ``_appkit_apps.py``."""
|
|
180
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
181
|
+
out = None
|
|
182
|
+
if "-o" in argv:
|
|
183
|
+
i = argv.index("-o")
|
|
184
|
+
if i + 1 >= len(argv):
|
|
185
|
+
argv = []
|
|
186
|
+
else:
|
|
187
|
+
out = argv[i + 1]
|
|
188
|
+
del argv[i : i + 2]
|
|
189
|
+
if len(argv) != 1 or argv[0] in ("-h", "--help"):
|
|
190
|
+
print("usage: python -m appkit.index APPS_FOLDER [-o OUT]")
|
|
191
|
+
print("Writes %s.py, the index of every APPS_FOLDER/<app>/app.json, for a frozen build." % MODULE)
|
|
192
|
+
return 0 if argv and argv[0] in ("-h", "--help") else 2
|
|
193
|
+
path = write(argv[0], out)
|
|
194
|
+
print("wrote", path)
|
|
195
|
+
return 0
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if __name__ == "__main__":
|
|
199
|
+
sys.exit(main())
|
appkit/index.pyi
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Build the app index a frozen build reads in place of the apps folder."""
|
|
5
|
+
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
MODULE: str
|
|
10
|
+
PACKAGE: str
|
|
11
|
+
INIT_TEXT: str
|
|
12
|
+
|
|
13
|
+
def check_icon(entry: str, info: dict[str, Any], path: str) -> None:
|
|
14
|
+
"""Raise `ValueError` when app `entry` shows a tile and has no valid `"icon"` in its app.json."""
|
|
15
|
+
def collect(folder: str) -> list[tuple[str, dict[str, Any]]]:
|
|
16
|
+
"""`[(entry, app.json contents), ...]` for every app in `folder`, sorted."""
|
|
17
|
+
def render(apps: list[tuple[str, dict[str, Any]]], source: str | None = None) -> str:
|
|
18
|
+
"""The `_appkit_apps` module's text for `apps` (see `collect`)."""
|
|
19
|
+
def write(folder: str, out: str | None = None) -> str:
|
|
20
|
+
"""Write the index of `folder` to `out`; returns the file's path."""
|
|
21
|
+
def freeze_apps(
|
|
22
|
+
folder: str, module: Callable[..., Any], package: Callable[..., Any], out_dir: str | None = None
|
|
23
|
+
) -> str:
|
|
24
|
+
"""From a MicroPython manifest: freeze every app in `folder` and its index.
|
|
25
|
+
|
|
26
|
+
`module` and `package` are the manifest's own functions. Returns the folder
|
|
27
|
+
the index was written to.
|
|
28
|
+
"""
|
|
29
|
+
def main(argv: list[str] | None = None) -> int:
|
|
30
|
+
"""`python -m appkit.index APPS [-o OUT]`: write `_appkit_apps.py`."""
|