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.5.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.5-py3-none-any.whl (108.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: plexi_sdk-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 53ddce5fe75a0e61ddc780669b6f6d252107500f0d09b9e08dfb369609f8474e
MD5 03600e737972c76d4272be58c48174f1
BLAKE2b-256 b6fcbe6a25d52d55c6251fc69e4d0c550c5222658cd6609dec0df42b0fedb1bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: plexi_sdk-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 108.5 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ed87826e8165791551e8f0dfabe7e769517ccae1ed18986bc0bdb493a5f600ad
MD5 109a39ff4419d33847f0aa781e65592f
BLAKE2b-256 436ff4a810f50f7135c3927e03918a404f1851adef0ddc32302019e410ca1be7

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