plexi-sdk 0.1.4__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.
- plexi_sdk/__init__.py +71 -0
- plexi_sdk/_app.py +1516 -0
- plexi_sdk/_constants.py +41 -0
- plexi_sdk/_emitter.py +1920 -0
- plexi_sdk/_pipe.py +92 -0
- plexi_sdk/_protocol.py +48 -0
- plexi_sdk/_render_context.py +1094 -0
- plexi_sdk/_state.py +47 -0
- plexi_sdk/_theme.py +150 -0
- plexi_sdk/_types.py +145 -0
- plexi_sdk/midi.py +222 -0
- plexi_sdk/py.typed +1 -0
- plexi_sdk/templates/__init__.py +0 -0
- plexi_sdk/templates/agent_init.py +49 -0
- plexi_sdk/templates/app_init.py +38 -0
- plexi_sdk/testing.py +574 -0
- plexi_sdk/ui.py +2128 -0
- plexi_sdk/widgets/__init__.py +27 -0
- plexi_sdk/widgets/button.py +63 -0
- plexi_sdk/widgets/keymap.py +51 -0
- plexi_sdk/widgets/list_view.py +170 -0
- plexi_sdk/widgets/scroll.py +100 -0
- plexi_sdk/widgets/text_area.py +219 -0
- plexi_sdk/widgets/text_buffer.py +337 -0
- plexi_sdk/widgets/text_input.py +70 -0
- plexi_sdk-0.1.4.dist-info/METADATA +117 -0
- plexi_sdk-0.1.4.dist-info/RECORD +28 -0
- plexi_sdk-0.1.4.dist-info/WHEEL +4 -0
plexi_sdk/__init__.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Python SDK v2 for Plexi PGAP apps.
|
|
2
|
+
|
|
3
|
+
Normal apps implement ``view()`` and return a component tree:
|
|
4
|
+
|
|
5
|
+
from plexi_sdk import App
|
|
6
|
+
from plexi_sdk.ui import AppBar, Column, FooterKeys, Label, Spacer
|
|
7
|
+
|
|
8
|
+
class CounterApp(App):
|
|
9
|
+
def on_init(self) -> None:
|
|
10
|
+
self.count = self.state.get("count", 0)
|
|
11
|
+
|
|
12
|
+
def view(self):
|
|
13
|
+
return Column([
|
|
14
|
+
AppBar("Counter"),
|
|
15
|
+
Spacer(grow=True),
|
|
16
|
+
Label(str(self.count), bold=True),
|
|
17
|
+
Spacer(grow=True),
|
|
18
|
+
FooterKeys([("+", "increment"), ("-", "decrement")]),
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
def on_key(self, key: str, mods: dict) -> None:
|
|
22
|
+
if key in ("plus", "equals"):
|
|
23
|
+
self.count += 1
|
|
24
|
+
elif key == "minus":
|
|
25
|
+
self.count -= 1
|
|
26
|
+
self.state.save({"count": self.count})
|
|
27
|
+
self.emit.schedule_render()
|
|
28
|
+
|
|
29
|
+
CounterApp().run()
|
|
30
|
+
|
|
31
|
+
Use ``on_render(ctx)`` only for games, animations, realtime visualizations, or
|
|
32
|
+
other pixel-control apps. Never override both ``view()`` and ``on_render(ctx)``.
|
|
33
|
+
|
|
34
|
+
Host-brokered actions live on ``self.emit``:
|
|
35
|
+
|
|
36
|
+
await self.emit.http_get(url) # requires net.http
|
|
37
|
+
await self.emit.secret_get("KEY") # requires secrets.get
|
|
38
|
+
await self.emit.ai_query("low", system, messages) # requires ai.query
|
|
39
|
+
|
|
40
|
+
Capabilities gate PGAP host APIs. Python apps are native subprocesses, not a
|
|
41
|
+
process sandbox.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
__version__ = "0.5.0"
|
|
45
|
+
SDK_ID = f"plexi-sdk-py/{__version__}"
|
|
46
|
+
|
|
47
|
+
from ._constants import (
|
|
48
|
+
TITLE, HEADING, BODY, CAPTION, HINT, MONO_BODY, MONO_SMALL,
|
|
49
|
+
PAD, PAD_TIGHT, HEADER_H, STATUS_H,
|
|
50
|
+
PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_CRITICAL,
|
|
51
|
+
rgba, dim,
|
|
52
|
+
)
|
|
53
|
+
from ._types import (
|
|
54
|
+
CapabilityDeniedError, VideoHandle,
|
|
55
|
+
RectCommand, TextCommand, BadgeCommand, TextInputSpec, ShortcutPair, NotifyOption,
|
|
56
|
+
)
|
|
57
|
+
from ._protocol import AiResponse, MidiPortInfo, MidiDeviceList, AudioDeviceInfo, AudioDeviceList, PROTOCOL_VERSION
|
|
58
|
+
from ._emitter import Emitter, _emit, _make_async_queue, _LOCK
|
|
59
|
+
from ._pipe import Pipe
|
|
60
|
+
from ._render_context import RenderContext, COMPACT_DEFAULT, REGULAR_DEFAULT
|
|
61
|
+
from ._app import App, Arg
|
|
62
|
+
from ._state import State as State
|
|
63
|
+
from .ui import (
|
|
64
|
+
Tabs as Tabs,
|
|
65
|
+
Grid as Grid,
|
|
66
|
+
Toggle as Toggle,
|
|
67
|
+
Clickable as Clickable,
|
|
68
|
+
ProgressBar as ProgressBar,
|
|
69
|
+
TextEdit as TextEdit,
|
|
70
|
+
)
|
|
71
|
+
from ._theme import theme, Theme, AppPalette
|