omnipython-applibs 0.1.2__tar.gz

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.
Files changed (170) hide show
  1. omnipython_applibs-0.1.2/LICENSE +21 -0
  2. omnipython_applibs-0.1.2/PKG-INFO +90 -0
  3. omnipython_applibs-0.1.2/README.md +74 -0
  4. omnipython_applibs-0.1.2/VERSION +1 -0
  5. omnipython_applibs-0.1.2/lib/appkit/__init__.py +52 -0
  6. omnipython_applibs-0.1.2/lib/appkit/__init__.pyi +17 -0
  7. omnipython_applibs-0.1.2/lib/appkit/data.py +149 -0
  8. omnipython_applibs-0.1.2/lib/appkit/data.pyi +25 -0
  9. omnipython_applibs-0.1.2/lib/appkit/foreground.py +357 -0
  10. omnipython_applibs-0.1.2/lib/appkit/foreground.pyi +45 -0
  11. omnipython_applibs-0.1.2/lib/appkit/home.py +19 -0
  12. omnipython_applibs-0.1.2/lib/appkit/home.pyi +8 -0
  13. omnipython_applibs-0.1.2/lib/appkit/hover.py +59 -0
  14. omnipython_applibs-0.1.2/lib/appkit/hover.pyi +13 -0
  15. omnipython_applibs-0.1.2/lib/appkit/index.py +199 -0
  16. omnipython_applibs-0.1.2/lib/appkit/index.pyi +30 -0
  17. omnipython_applibs-0.1.2/lib/appkit/launcher.py +1075 -0
  18. omnipython_applibs-0.1.2/lib/appkit/launcher.pyi +96 -0
  19. omnipython_applibs-0.1.2/lib/appkit/manifest.py +75 -0
  20. omnipython_applibs-0.1.2/lib/appkit/manifest.pyi +8 -0
  21. omnipython_applibs-0.1.2/lib/appkit/net.py +167 -0
  22. omnipython_applibs-0.1.2/lib/appkit/net.pyi +34 -0
  23. omnipython_applibs-0.1.2/lib/appkit/places.py +202 -0
  24. omnipython_applibs-0.1.2/lib/appkit/places.pyi +39 -0
  25. omnipython_applibs-0.1.2/lib/appkit/py.typed +0 -0
  26. omnipython_applibs-0.1.2/lib/appkit/scope.py +636 -0
  27. omnipython_applibs-0.1.2/lib/appkit/scope.pyi +110 -0
  28. omnipython_applibs-0.1.2/lib/appkit/shell.py +121 -0
  29. omnipython_applibs-0.1.2/lib/appkit/shell.pyi +32 -0
  30. omnipython_applibs-0.1.2/lib/appkit/worker.py +409 -0
  31. omnipython_applibs-0.1.2/lib/appkit/worker.pyi +83 -0
  32. omnipython_applibs-0.1.2/lib/controlkit/__init__.py +19 -0
  33. omnipython_applibs-0.1.2/lib/controlkit/__init__.pyi +10 -0
  34. omnipython_applibs-0.1.2/lib/controlkit/_draw.py +88 -0
  35. omnipython_applibs-0.1.2/lib/controlkit/_safe.py +29 -0
  36. omnipython_applibs-0.1.2/lib/controlkit/dotmatrix.py +101 -0
  37. omnipython_applibs-0.1.2/lib/controlkit/dotmatrix.pyi +23 -0
  38. omnipython_applibs-0.1.2/lib/controlkit/encoder.py +297 -0
  39. omnipython_applibs-0.1.2/lib/controlkit/encoder.pyi +55 -0
  40. omnipython_applibs-0.1.2/lib/controlkit/font5x7.py +22 -0
  41. omnipython_applibs-0.1.2/lib/controlkit/font5x7.pyi +11 -0
  42. omnipython_applibs-0.1.2/lib/controlkit/lamp_button.py +92 -0
  43. omnipython_applibs-0.1.2/lib/controlkit/lamp_button.pyi +40 -0
  44. omnipython_applibs-0.1.2/lib/controlkit/meter.py +86 -0
  45. omnipython_applibs-0.1.2/lib/controlkit/meter.pyi +30 -0
  46. omnipython_applibs-0.1.2/lib/controlkit/mock.py +116 -0
  47. omnipython_applibs-0.1.2/lib/controlkit/mock.pyi +35 -0
  48. omnipython_applibs-0.1.2/lib/controlkit/pad_grid.py +113 -0
  49. omnipython_applibs-0.1.2/lib/controlkit/pad_grid.pyi +41 -0
  50. omnipython_applibs-0.1.2/lib/controlkit/py.typed +0 -0
  51. omnipython_applibs-0.1.2/lib/controlkit/slider.py +185 -0
  52. omnipython_applibs-0.1.2/lib/controlkit/slider.pyi +49 -0
  53. omnipython_applibs-0.1.2/lib/controlkit/sprites.py +279 -0
  54. omnipython_applibs-0.1.2/lib/controlkit/sprites.pyi +22 -0
  55. omnipython_applibs-0.1.2/lib/controlkit/theme.py +120 -0
  56. omnipython_applibs-0.1.2/lib/controlkit/theme.pyi +15 -0
  57. omnipython_applibs-0.1.2/lib/deskkit/__init__.py +74 -0
  58. omnipython_applibs-0.1.2/lib/deskkit/__init__.pyi +18 -0
  59. omnipython_applibs-0.1.2/lib/deskkit/forecast.py +261 -0
  60. omnipython_applibs-0.1.2/lib/deskkit/forecast.pyi +40 -0
  61. omnipython_applibs-0.1.2/lib/deskkit/localtime.py +215 -0
  62. omnipython_applibs-0.1.2/lib/deskkit/localtime.pyi +33 -0
  63. omnipython_applibs-0.1.2/lib/deskkit/py.typed +0 -0
  64. omnipython_applibs-0.1.2/lib/deskkit/shell.py +113 -0
  65. omnipython_applibs-0.1.2/lib/deskkit/shell.pyi +33 -0
  66. omnipython_applibs-0.1.2/lib/omnipython_applibs.egg-info/PKG-INFO +90 -0
  67. omnipython_applibs-0.1.2/lib/omnipython_applibs.egg-info/SOURCES.txt +168 -0
  68. omnipython_applibs-0.1.2/lib/omnipython_applibs.egg-info/dependency_links.txt +1 -0
  69. omnipython_applibs-0.1.2/lib/omnipython_applibs.egg-info/top_level.txt +9 -0
  70. omnipython_applibs-0.1.2/lib/programkit/__init__.py +27 -0
  71. omnipython_applibs-0.1.2/lib/programkit/__init__.pyi +8 -0
  72. omnipython_applibs-0.1.2/lib/programkit/board.py +56 -0
  73. omnipython_applibs-0.1.2/lib/programkit/board.pyi +20 -0
  74. omnipython_applibs-0.1.2/lib/programkit/press.py +63 -0
  75. omnipython_applibs-0.1.2/lib/programkit/press.pyi +17 -0
  76. omnipython_applibs-0.1.2/lib/programkit/py.typed +0 -0
  77. omnipython_applibs-0.1.2/lib/programkit/rows.py +149 -0
  78. omnipython_applibs-0.1.2/lib/programkit/rows.pyi +34 -0
  79. omnipython_applibs-0.1.2/lib/sayso/__init__.py +109 -0
  80. omnipython_applibs-0.1.2/lib/sayso/__init__.pyi +124 -0
  81. omnipython_applibs-0.1.2/lib/sayso/auth.py +811 -0
  82. omnipython_applibs-0.1.2/lib/sayso/auth.pyi +102 -0
  83. omnipython_applibs-0.1.2/lib/sayso/client.py +1286 -0
  84. omnipython_applibs-0.1.2/lib/sayso/client.pyi +138 -0
  85. omnipython_applibs-0.1.2/lib/sayso/keepalive.py +371 -0
  86. omnipython_applibs-0.1.2/lib/sayso/keepalive.pyi +53 -0
  87. omnipython_applibs-0.1.2/lib/sayso/local.py +85 -0
  88. omnipython_applibs-0.1.2/lib/sayso/local.pyi +28 -0
  89. omnipython_applibs-0.1.2/lib/sayso/object_specs.py +706 -0
  90. omnipython_applibs-0.1.2/lib/sayso/object_specs.pyi +8 -0
  91. omnipython_applibs-0.1.2/lib/sayso/objects.py +411 -0
  92. omnipython_applibs-0.1.2/lib/sayso/objects.pyi +854 -0
  93. omnipython_applibs-0.1.2/lib/sayso/py.typed +0 -0
  94. omnipython_applibs-0.1.2/lib/sayso/schema_coverage.py +210 -0
  95. omnipython_applibs-0.1.2/lib/sayso/schema_coverage.pyi +13 -0
  96. omnipython_applibs-0.1.2/lib/sayso/transport.py +426 -0
  97. omnipython_applibs-0.1.2/lib/sayso/transport.pyi +47 -0
  98. omnipython_applibs-0.1.2/lib/songmodel/__init__.py +30 -0
  99. omnipython_applibs-0.1.2/lib/songmodel/__init__.pyi +9 -0
  100. omnipython_applibs-0.1.2/lib/songmodel/link.py +189 -0
  101. omnipython_applibs-0.1.2/lib/songmodel/link.pyi +53 -0
  102. omnipython_applibs-0.1.2/lib/songmodel/model.py +238 -0
  103. omnipython_applibs-0.1.2/lib/songmodel/model.pyi +40 -0
  104. omnipython_applibs-0.1.2/lib/songmodel/page.html +225 -0
  105. omnipython_applibs-0.1.2/lib/songmodel/page_data.py +236 -0
  106. omnipython_applibs-0.1.2/lib/songmodel/page_data.pyi +6 -0
  107. omnipython_applibs-0.1.2/lib/songmodel/py.typed +0 -0
  108. omnipython_applibs-0.1.2/lib/soundmodule/__init__.py +7 -0
  109. omnipython_applibs-0.1.2/lib/soundmodule/__init__.pyi +6 -0
  110. omnipython_applibs-0.1.2/lib/soundmodule/engine.py +1001 -0
  111. omnipython_applibs-0.1.2/lib/soundmodule/engine.pyi +196 -0
  112. omnipython_applibs-0.1.2/lib/soundmodule/names.py +298 -0
  113. omnipython_applibs-0.1.2/lib/soundmodule/names.pyi +30 -0
  114. omnipython_applibs-0.1.2/lib/soundmodule/pipes.py +105 -0
  115. omnipython_applibs-0.1.2/lib/soundmodule/pipes.pyi +31 -0
  116. omnipython_applibs-0.1.2/lib/soundmodule/py.typed +0 -0
  117. omnipython_applibs-0.1.2/lib/soundmodule/run.py +249 -0
  118. omnipython_applibs-0.1.2/lib/soundmodule/run.pyi +49 -0
  119. omnipython_applibs-0.1.2/lib/spectrum/__init__.py +72 -0
  120. omnipython_applibs-0.1.2/lib/spectrum/__init__.pyi +30 -0
  121. omnipython_applibs-0.1.2/lib/spectrum/analyzer.py +231 -0
  122. omnipython_applibs-0.1.2/lib/spectrum/analyzer.pyi +67 -0
  123. omnipython_applibs-0.1.2/lib/spectrum/fake_music.py +201 -0
  124. omnipython_applibs-0.1.2/lib/spectrum/fake_music.pyi +36 -0
  125. omnipython_applibs-0.1.2/lib/spectrum/pump_levels.py +126 -0
  126. omnipython_applibs-0.1.2/lib/spectrum/pump_levels.pyi +46 -0
  127. omnipython_applibs-0.1.2/lib/spectrum/py.typed +0 -0
  128. omnipython_applibs-0.1.2/lib/spectrum/spectrum_view.py +403 -0
  129. omnipython_applibs-0.1.2/lib/spectrum/spectrum_view.pyi +80 -0
  130. omnipython_applibs-0.1.2/lib/touchkit/__init__.py +4 -0
  131. omnipython_applibs-0.1.2/lib/touchkit/__init__.pyi +4 -0
  132. omnipython_applibs-0.1.2/lib/touchkit/cam.py +146 -0
  133. omnipython_applibs-0.1.2/lib/touchkit/cam.pyi +35 -0
  134. omnipython_applibs-0.1.2/lib/touchkit/clock.py +18 -0
  135. omnipython_applibs-0.1.2/lib/touchkit/clock.pyi +6 -0
  136. omnipython_applibs-0.1.2/lib/touchkit/ecp.py +134 -0
  137. omnipython_applibs-0.1.2/lib/touchkit/ecp.pyi +28 -0
  138. omnipython_applibs-0.1.2/lib/touchkit/net.py +347 -0
  139. omnipython_applibs-0.1.2/lib/touchkit/net.pyi +27 -0
  140. omnipython_applibs-0.1.2/lib/touchkit/py.typed +0 -0
  141. omnipython_applibs-0.1.2/lib/touchkit/settings.py +85 -0
  142. omnipython_applibs-0.1.2/lib/touchkit/settings.pyi +17 -0
  143. omnipython_applibs-0.1.2/lib/touchkit/shell.py +268 -0
  144. omnipython_applibs-0.1.2/lib/touchkit/shell.pyi +42 -0
  145. omnipython_applibs-0.1.2/lib/touchkit/ui.py +167 -0
  146. omnipython_applibs-0.1.2/lib/touchkit/ui.pyi +53 -0
  147. omnipython_applibs-0.1.2/pyproject.toml +32 -0
  148. omnipython_applibs-0.1.2/setup.cfg +4 -0
  149. omnipython_applibs-0.1.2/tests/test_board_name.py +132 -0
  150. omnipython_applibs-0.1.2/tests/test_camera.py +220 -0
  151. omnipython_applibs-0.1.2/tests/test_controls.py +102 -0
  152. omnipython_applibs-0.1.2/tests/test_deskkit.py +412 -0
  153. omnipython_applibs-0.1.2/tests/test_engine.py +134 -0
  154. omnipython_applibs-0.1.2/tests/test_folders.py +44 -0
  155. omnipython_applibs-0.1.2/tests/test_gamepad.py +264 -0
  156. omnipython_applibs-0.1.2/tests/test_hover.py +108 -0
  157. omnipython_applibs-0.1.2/tests/test_hover_browser.py +172 -0
  158. omnipython_applibs-0.1.2/tests/test_huey.py +301 -0
  159. omnipython_applibs-0.1.2/tests/test_midicontroller.py +525 -0
  160. omnipython_applibs-0.1.2/tests/test_panel_contract.py +204 -0
  161. omnipython_applibs-0.1.2/tests/test_perch.py +102 -0
  162. omnipython_applibs-0.1.2/tests/test_relative_imports.py +75 -0
  163. omnipython_applibs-0.1.2/tests/test_repl_app.py +149 -0
  164. omnipython_applibs-0.1.2/tests/test_songmodel_page.py +114 -0
  165. omnipython_applibs-0.1.2/tests/test_soundmodule_names.py +194 -0
  166. omnipython_applibs-0.1.2/tests/test_stompbox.py +80 -0
  167. omnipython_applibs-0.1.2/tests/test_synthstation_govern.py +146 -0
  168. omnipython_applibs-0.1.2/tests/test_synthstation_midi.py +60 -0
  169. omnipython_applibs-0.1.2/tests/test_touchkit_shell.py +506 -0
  170. omnipython_applibs-0.1.2/tests/test_vamp.py +266 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brad Barnett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: omnipython-applibs
3
+ Version: 0.1.2
4
+ Summary: The libraries apps share: appkit, controlkit, deskkit, programkit, sayso, songmodel, soundmodule, spectrum and touchkit
5
+ Author: Brad Barnett
6
+ License: MIT
7
+ Keywords: lvgl,controls,apps,micropython
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: Implementation :: MicroPython
12
+ Classifier: Programming Language :: Python :: Implementation :: CPython
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ ![Ostinato, the pattern sequencer, playing a four-bar drum pattern in its desktop window](docs/ostinato.png)
18
+
19
+ # Apps
20
+
21
+ The apps for PyDevices: things you run on a board or a desktop. A Home app lives in `apps/`; a program, which runs on its own, lives in [`programs/`](programs/README.md).
22
+
23
+ ## Install
24
+
25
+ On a Wi-Fi board, one line installs an app with what it needs, and another
26
+ starts Home at boot ([install an app](docs/guides/install-an-app.md)):
27
+
28
+ ```python
29
+ import omip
30
+ omip.install("github:PyDevices/apps/apps/home")
31
+ omip.install("github:PyDevices/apps/apps/home/main.py", target="/")
32
+ ```
33
+
34
+ On a computer, the apps are used from a clone, beside the libraries they build on:
35
+
36
+ ```bash
37
+ git clone https://github.com/PyDevices/apps
38
+ git clone https://github.com/PyDevices/audioinstruments
39
+ git clone https://github.com/PyDevices/audioeffects
40
+ git clone https://github.com/PyDevices/audiodsp
41
+ pip install ./audiodsp numpy
42
+ pip install --no-deps ./audioinstruments ./audioeffects/lib/audioeffects
43
+ ```
44
+
45
+ The libraries the apps share (`appkit`, `controlkit`, `deskkit`, `sayso`,
46
+ `songmodel`, `soundmodule`, `spectrum` and `touchkit`) also install as a package, under
47
+ their own names. Each is imported directly, as in `import controlkit`:
48
+
49
+ ```bash
50
+ pip install omnipython-applibs
51
+ ```
52
+
53
+ On a board, use `mip.install("applibs", index="https://lib.omnipython.org")`.
54
+ To freeze them into firmware, name this repository's folder as a module of the
55
+ build: its [manifest.py](manifest.py) lists them.
56
+
57
+ ## Try it
58
+
59
+ Render a MIDI file through the sound module to a WAV, with no MIDI hardware.
60
+ The sound comes from a General MIDI SoundFont (`.sf2`) that you supply, such
61
+ as [GeneralUser GS](https://schristiancollins.com/generaluser.php):
62
+
63
+ ```bash
64
+ cd apps
65
+ python tools/render_mid.py tests/midi/musicbox1_spooky_waltz.mid take.wav --bank GeneralUser-GS.sf2 --path lib
66
+ ```
67
+
68
+ It writes `take.wav`, 53 seconds of celesta, and prints what it measured:
69
+
70
+ ```
71
+ notes 261
72
+ played 261
73
+ held 0
74
+ sounding 0
75
+ song 53.310
76
+ render 0.947
77
+ reverb 0
78
+ chorus 0
79
+ soundmodule: cpython 3.12.3 (linux): 0 bytes of MIDI, 0 Identity Requests answered, render behind by at most 0 ms while playing (0 ms before the first note)
80
+ channel 1: 157 notes, bank 0:0 program 8, Celesta
81
+ channel 2: 56 notes, bank 0:0 program 8, Celesta
82
+ channel 3: 32 notes, bank 0:0 program 8, Celesta
83
+ channel 16: 16 notes, bank 0:0 program 8, Celesta
84
+ ```
85
+
86
+ `played` equals `notes` when every note sounded. The `render` and interpreter lines are yours to differ on.
87
+
88
+ [Docs](docs/index.md) | [Examples](https://gallery.omnipython.org) | [Roadmap](ROADMAP.md)
89
+
90
+ Made by [PyDevices](https://pydevices.com).
@@ -0,0 +1,74 @@
1
+ ![Ostinato, the pattern sequencer, playing a four-bar drum pattern in its desktop window](docs/ostinato.png)
2
+
3
+ # Apps
4
+
5
+ The apps for PyDevices: things you run on a board or a desktop. A Home app lives in `apps/`; a program, which runs on its own, lives in [`programs/`](programs/README.md).
6
+
7
+ ## Install
8
+
9
+ On a Wi-Fi board, one line installs an app with what it needs, and another
10
+ starts Home at boot ([install an app](docs/guides/install-an-app.md)):
11
+
12
+ ```python
13
+ import omip
14
+ omip.install("github:PyDevices/apps/apps/home")
15
+ omip.install("github:PyDevices/apps/apps/home/main.py", target="/")
16
+ ```
17
+
18
+ On a computer, the apps are used from a clone, beside the libraries they build on:
19
+
20
+ ```bash
21
+ git clone https://github.com/PyDevices/apps
22
+ git clone https://github.com/PyDevices/audioinstruments
23
+ git clone https://github.com/PyDevices/audioeffects
24
+ git clone https://github.com/PyDevices/audiodsp
25
+ pip install ./audiodsp numpy
26
+ pip install --no-deps ./audioinstruments ./audioeffects/lib/audioeffects
27
+ ```
28
+
29
+ The libraries the apps share (`appkit`, `controlkit`, `deskkit`, `sayso`,
30
+ `songmodel`, `soundmodule`, `spectrum` and `touchkit`) also install as a package, under
31
+ their own names. Each is imported directly, as in `import controlkit`:
32
+
33
+ ```bash
34
+ pip install omnipython-applibs
35
+ ```
36
+
37
+ On a board, use `mip.install("applibs", index="https://lib.omnipython.org")`.
38
+ To freeze them into firmware, name this repository's folder as a module of the
39
+ build: its [manifest.py](manifest.py) lists them.
40
+
41
+ ## Try it
42
+
43
+ Render a MIDI file through the sound module to a WAV, with no MIDI hardware.
44
+ The sound comes from a General MIDI SoundFont (`.sf2`) that you supply, such
45
+ as [GeneralUser GS](https://schristiancollins.com/generaluser.php):
46
+
47
+ ```bash
48
+ cd apps
49
+ python tools/render_mid.py tests/midi/musicbox1_spooky_waltz.mid take.wav --bank GeneralUser-GS.sf2 --path lib
50
+ ```
51
+
52
+ It writes `take.wav`, 53 seconds of celesta, and prints what it measured:
53
+
54
+ ```
55
+ notes 261
56
+ played 261
57
+ held 0
58
+ sounding 0
59
+ song 53.310
60
+ render 0.947
61
+ reverb 0
62
+ chorus 0
63
+ soundmodule: cpython 3.12.3 (linux): 0 bytes of MIDI, 0 Identity Requests answered, render behind by at most 0 ms while playing (0 ms before the first note)
64
+ channel 1: 157 notes, bank 0:0 program 8, Celesta
65
+ channel 2: 56 notes, bank 0:0 program 8, Celesta
66
+ channel 3: 32 notes, bank 0:0 program 8, Celesta
67
+ channel 16: 16 notes, bank 0:0 program 8, Celesta
68
+ ```
69
+
70
+ `played` equals `notes` when every note sounded. The `render` and interpreter lines are yours to differ on.
71
+
72
+ [Docs](docs/index.md) | [Examples](https://gallery.omnipython.org) | [Roadmap](ROADMAP.md)
73
+
74
+ Made by [PyDevices](https://pydevices.com).
@@ -0,0 +1 @@
1
+ 0.1.2
@@ -0,0 +1,52 @@
1
+ # SPDX-FileCopyrightText: 2026 Brad Barnett
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """appkit: apps you can switch between, and a launcher to run them.
5
+
6
+ ::
7
+
8
+ import appkit
9
+ appkit.run() # a home screen of every app in ./apps
10
+ appkit.run("hello") # one app, alone
11
+ """
12
+
13
+ from .foreground import serve
14
+ from .launcher import Launcher, host, run_pending_script
15
+ from .scope import AppScope
16
+ from .shell import Shell
17
+
18
+
19
+ def run(name=None, folder="apps", *, data_root=None):
20
+ """Run the apps in *folder*: a home screen listing them, or app *name* alone.
21
+
22
+ The home screen is the folder's own app named ``home`` when it has one,
23
+ and otherwise appkit's list of buttons, ``appkit.home``.
24
+
25
+ It ends in the main-thread loop, `serve`, and returns the
26
+ ``Launcher`` when the program quits. In a browser, where the page has
27
+ the main thread, it returns the launcher at once. *data_root* moves
28
+ every app's ``data_dir`` and the launcher's restart file (see
29
+ ``appkit.data``). A plain script the home screen started runs here
30
+ first, before the display opens, and doesn't return.
31
+ """
32
+ if run_pending_script(data_root):
33
+ return None # a browser, reloading
34
+ from display_driver import app # the one App every LVGL program shares
35
+
36
+ launcher = Launcher(app)
37
+ launcher.scan(folder)
38
+ if name is None:
39
+ _use_home(launcher)
40
+ launcher.shell = Shell(launcher)
41
+ launcher.boot(name)
42
+ if host() != "browser":
43
+ serve(app)
44
+ return launcher
45
+
46
+
47
+ def _use_home(launcher):
48
+ """Make ``home`` the launcher's home screen: the folder's own app named
49
+ home when the scan found one, else appkit's list of buttons."""
50
+ if "home" not in launcher.names:
51
+ launcher.add("home", "appkit.home")
52
+ launcher.home = "home"
@@ -0,0 +1,17 @@
1
+ # SPDX-FileCopyrightText: 2026 Brad Barnett
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """appkit: apps you can switch between, and a launcher to run them."""
5
+
6
+ from .foreground import serve as serve
7
+ from .launcher import Launcher as Launcher, host as host, run_pending_script as run_pending_script
8
+ from .scope import AppScope as AppScope
9
+ from .shell import Shell as Shell
10
+
11
+ def run(name: str | None = None, folder: str = 'apps', *, data_root: str | None = None) -> Launcher | None:
12
+ """Run the apps in `folder`: a home screen listing them, or app `name` alone.
13
+
14
+ Ends in the main-thread loop and returns the `Launcher` when the program
15
+ quits. In a browser it returns the launcher at once. `data_root` moves every
16
+ app's `data_dir` and the launcher's restart file.
17
+ """
@@ -0,0 +1,149 @@
1
+ # SPDX-FileCopyrightText: 2026 Brad Barnett
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """Where apps keep their files: the data root, and a folder per app under it.
5
+
6
+ The data root is one setting for the whole program. Each app's folder is
7
+ ``<root>/<app>``, made on first use. The launcher's restart file lives in
8
+ the root too. By default the root is:
9
+
10
+ ============== ==========================================================
11
+ Linux ``$XDG_DATA_HOME/appkit``, or ``~/.local/share/appkit``
12
+ Windows ``%LOCALAPPDATA%\\appkit``
13
+ macOS ``~/Library/Application Support/appkit``
14
+ a board ``/data`` (``/flash/data`` on an STM32, whose ``/`` only holds mounts)
15
+ the browser ``/data``
16
+ ============== ==========================================================
17
+
18
+ ``appkit.run(data_root=...)``, the same argument to ``Shell`` or
19
+ `set_root` moves it everywhere. Without one, ``APPKIT_DATA`` moves it
20
+ on a desktop.
21
+ """
22
+
23
+ import sys
24
+
25
+ #: Platforms that are a desktop operating system, whatever the interpreter.
26
+ DESKTOPS = ("linux", "darwin", "win32", "cygwin", "freebsd", "openbsd", "netbsd")
27
+
28
+ _root = None
29
+
30
+
31
+ def desktop(platform=None, implementation=None):
32
+ """True on a desktop operating system (CPython, or MicroPython's unix or
33
+ Windows port), False on a board or in the browser."""
34
+ platform = platform or sys.platform
35
+ implementation = implementation or sys.implementation.name
36
+ if platform in ("webassembly", "emscripten", "wasi"):
37
+ return False
38
+ if implementation == "cpython":
39
+ return True
40
+ return platform in DESKTOPS
41
+
42
+
43
+ def _getenv(name):
44
+ import os
45
+
46
+ getenv = getattr(os, "getenv", None) # boards have none
47
+ if getenv is None:
48
+ return None
49
+ try:
50
+ return getenv(name) or None
51
+ except Exception:
52
+ return None
53
+
54
+
55
+ def default_root(platform=None, implementation=None, getenv=None):
56
+ """The data root this host uses when nothing sets one.
57
+
58
+ *platform*, *implementation* and *getenv* stand in for ``sys.platform``,
59
+ ``sys.implementation.name`` and ``os.getenv``, to ask about another host.
60
+ """
61
+ platform = platform or sys.platform
62
+ if getenv is None:
63
+ getenv = _getenv
64
+ if not desktop(platform, implementation):
65
+ # The stm32 port's "/" is only where /flash and /sd are mounted, and
66
+ # a folder can't be made there.
67
+ return "/flash/data" if platform == "pyboard" else "/data"
68
+ explicit = getenv("APPKIT_DATA")
69
+ if explicit:
70
+ return explicit
71
+ if platform == "win32":
72
+ base = getenv("LOCALAPPDATA")
73
+ if not base:
74
+ base = (getenv("USERPROFILE") or ".") + "\\AppData\\Local"
75
+ return base + "\\appkit"
76
+ home = getenv("HOME") or getenv("USERPROFILE") or "."
77
+ if platform == "darwin":
78
+ # Untested: macOS is community-supported.
79
+ return home + "/Library/Application Support/appkit"
80
+ base = getenv("XDG_DATA_HOME") or home + "/.local/share"
81
+ return base + "/appkit"
82
+
83
+
84
+ def root():
85
+ """The data root: what `set_root` set, else `default_root`."""
86
+ return _root if _root is not None else default_root()
87
+
88
+
89
+ def set_root(path):
90
+ """Move the data root for the whole program; None goes back to the default."""
91
+ global _root
92
+ if path is not None:
93
+ path = str(path)
94
+ while len(path) > 1 and path[-1] in "/\\" and not path.endswith(":\\"):
95
+ path = path[:-1]
96
+ _root = path
97
+
98
+
99
+ def join(base, *parts):
100
+ """*base* and *parts* joined with the separator *base* already uses."""
101
+ sep = "\\" if ("\\" in base and "/" not in base) else "/"
102
+ out = base
103
+ for part in parts:
104
+ if out and out[-1] in "/\\":
105
+ out += part
106
+ else:
107
+ out += sep + part
108
+ return out
109
+
110
+
111
+ def _exists(path):
112
+ import os
113
+
114
+ try:
115
+ os.stat(path)
116
+ return True
117
+ except OSError:
118
+ return False
119
+
120
+
121
+ def makedirs(path):
122
+ """Make folder *path* and any parents it needs; fine if it exists.
123
+
124
+ ``os.makedirs`` for MicroPython, which has only ``os.mkdir``.
125
+ """
126
+ import os
127
+
128
+ if _exists(path):
129
+ return path
130
+ # Every prefix, shortest first: "/a", "/a/b", ... or "C:\\a", "C:\\a\\b".
131
+ prefixes = []
132
+ for i in range(1, len(path)):
133
+ if path[i] in "/\\" and path[i - 1] not in "/\\:":
134
+ prefixes.append(path[:i])
135
+ prefixes.append(path)
136
+ for p in prefixes:
137
+ if not _exists(p):
138
+ try:
139
+ os.mkdir(p)
140
+ except OSError:
141
+ pass # made meanwhile, or a drive or root we can't make
142
+ if not _exists(path):
143
+ raise OSError("could not make the folder %r" % (path,))
144
+ return path
145
+
146
+
147
+ def app_dir(name, base=None):
148
+ """App *name*'s folder under *base* (default: the data root), made if missing."""
149
+ return makedirs(join(base if base is not None else root(), name))
@@ -0,0 +1,25 @@
1
+ # SPDX-FileCopyrightText: 2026 Brad Barnett
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """Where apps keep their files: the data root, and a folder per app under it."""
5
+
6
+ from collections.abc import Callable
7
+
8
+ DESKTOPS: tuple[str, ...]
9
+
10
+ def desktop(platform: str | None = None, implementation: str | None = None) -> bool:
11
+ """True on a desktop operating system, False on a board or in the browser."""
12
+ def default_root(
13
+ platform: str | None = None, implementation: str | None = None, getenv: Callable[[str], str | None] | None = None
14
+ ) -> str:
15
+ """The data root this host uses when nothing sets one."""
16
+ def root() -> str:
17
+ """The data root: what `set_root` set, else `default_root`."""
18
+ def set_root(path: str | None) -> None:
19
+ """Move the data root for the whole program; None goes back to the default."""
20
+ def join(base: str, *parts: str) -> str:
21
+ """`base` and `parts` joined with the separator `base` already uses."""
22
+ def makedirs(path: str) -> str:
23
+ """Make folder `path` and any parents it needs; fine if it exists."""
24
+ def app_dir(name: str, base: str | None = None) -> str:
25
+ """App `name`'s folder under `base` (default: the data root), made if missing."""