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 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.7.tar.gz (99.9 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.7-py3-none-any.whl (109.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: plexi_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 99.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.7.tar.gz
Algorithm Hash digest
SHA256 c15f89fef675f650afd3f1769ace44fef10d5714fdf5256a498d01e9b1a1a947
MD5 a9138a21962d76e2a1bf17efa2f440fc
BLAKE2b-256 55374c1b947b233db927eef2ead9918b7c90c1d9218d049fb2cdd2ea428e3a30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: plexi_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 109.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fc43e6b38bac1ed388eb7c430be531531d7b0f0e6a2d289746628648d877985e
MD5 5d18b5ae45915939ca12be718526b532
BLAKE2b-256 1dcd8af3e0883352cd155236a6fdbbe26d949f3fedd860e7bca67387434a097a

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