Skip to main content

Python SDK for building Plexi apps via the PGAP v3 protocol

Project description

plexi-sdk

Python SDK v2 for building Plexi PGAP apps.

SDK v2 is the Python authoring API. PGAP v3 (pgap/3) is the host/app wire protocol the SDK speaks.

Full API reference: plexi_sdk/__init__.py and docs/sdk-v2.md.

Install For SDK Development

uv pip install -e ./sdk/python

Run from the repo root. uv creates .venv automatically if needed. Changes to sdk/python/plexi_sdk/ take effect immediately in that environment.

Apps running inside Plexi use the SDK copy injected by the host on PYTHONPATH; the editable install is for type checking, tests, and local development.

Verify the install:

source .venv/bin/activate
python3 -c "from plexi_sdk import App; print('ok')"

App Pattern

Normal apps implement view() and return a component tree:

from plexi_sdk import App
from plexi_sdk.ui import AppBar, Column, FooterKeys, Label, Spacer


class CounterApp(App):
    def on_init(self) -> None:
        self.count = self.state.get("count", 0)

    def view(self):
        return Column([
            AppBar("Counter"),
            Spacer(grow=True),
            Label(str(self.count), bold=True),
            Spacer(grow=True),
            FooterKeys([("+", "increment"), ("-", "decrement")]),
        ])

    def on_key(self, key: str, mods: dict) -> None:
        if key in ("plus", "equals"):
            self.count += 1
        elif key == "minus":
            self.count -= 1
        self.state.save({"count": self.count})
        self.emit.schedule_render()


CounterApp().run()

Use on_render(ctx) only for games, animations, realtime visualizations, or other pixel-control apps.

Keyboard Conventions

Keys arrive in on_key(self, key, mods) as lowercase canonical strings.

Physical key key string
Enter / Return "return"
Escape "escape"
Backspace "backspace"
Tab "tab"
Space "space"
Arrow keys "up" / "down" / "left" / "right"

Use "return", not "Enter". Use "escape", not "Escape".

Common list bindings:

Key Action
j / "down" Move selection down
k / "up" Move selection up
"return" Open selected item
"escape" Exit list or go back

State And Host I/O

self.state.get("key", default)
self.state.save({"key": value})
self.emit.schedule_render()
await self.emit.http_get(url)
await self.emit.secret_get("API_KEY")
await self.emit.ai_query("low", system, messages)

Declare capabilities in manifest.toml before using brokered host powers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plexi_sdk-0.1.4.tar.gz (98.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plexi_sdk-0.1.4-py3-none-any.whl (108.4 kB view details)

Uploaded Python 3

File details

Details for the file plexi_sdk-0.1.4.tar.gz.

File metadata

  • Download URL: plexi_sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 98.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plexi_sdk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b929682f49d43c2f19976fa7a4bfe3dccdefb7c07f1fef7bfb02abe426288ede
MD5 fff2db0a5dd8015493ea85df93249a43
BLAKE2b-256 f904a0af6589ce7815f5738bf292d5d5be9bf5061fd329e3c7efa010922800e0

See more details on using hashes here.

File details

Details for the file plexi_sdk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: plexi_sdk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 108.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plexi_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e94fd695f8e8a2f4d85372f270d2e1ee632a6084cce74342d8109042321dcd69
MD5 c4993b8632a7d975f794bf01b8fc1b05
BLAKE2b-256 c1d5082b13b06afca3599de28a9d2833942589796a42bbdd2de0acaa9e9c00d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page