ppx-py
PPX 是一个开源的跨平台桌面应用框架:用 Python 编写业务,用 JavaScript 构建界面,为 Windows、macOS 和 Linux 生成桌面客户端。可以选择 Vanilla JavaScript、Vue 或 React,不需要维护 pywebview 入口、PyInstaller spec 或安装器脚本。
PPX 由两个包配合工作:ppx-py 提供 Python 运行时、开发命令和三端打包;ppx-js 提供前端调用、事件订阅和 TypeScript 声明。旧 V5 项目请查阅 V5 归档文档,两代接口不能直接混用。
PPX 的 Python 运行时、命令行与三端打包器。开发者通过 ppx new/init/icon/dev/doctor/update/build 使用它,不需要接触框架内部实现。
安装与创建项目
需要 Python 3.10+。前端工具链需要 Node.js 22.13+ 与 pnpm 11.x。
python -m pip install ppx-py==6.0.0
ppx new my-app --frontend vue
cd my-app
ppx init
ppx dev
新项目只暴露 Python 业务目录 api/、Web 前端目录 gui/、可替换图片目录 ppx/assets/,以及 ppx.toml、ppx.lock 等配置文件。框架入口、窗口协调、PyInstaller spec 和三端安装器脚本均在包内实现并按需生成。
Python 业务 API
from ppx_py import api_method
@api_method("user.greet")
def greet(name: str):
return {"message": f"你好,{name}!"}
也可以直接注册 async def。在 ppx.toml 的 [python].modules 中声明业务模块后,PPX 会自动导入并注册带 @api_method 的函数。普通业务项目不需要创建 Application、Bridge 或 main.py。
使用 resource_path() 读取打包前后位置一致的业务资源,使用 app_data_path() 获取当前操作系统规范的可写用户数据路径。内置 RPC 还提供打开/保存文件对话框、目录选择、窗口状态与最小化/最大化/全屏/关闭控制。
命令
ppx new NAME --frontend TEMPLATE 创建 vanilla、vue 或 react 项目
ppx init 安装业务依赖并诊断
ppx doctor 检查配置、版本、资源和平台工具
ppx doctor --json 输出机器可读诊断结果
ppx icon SOURCE 从方形主图生成三端图标
ppx dev 启动前端并打开桌面窗口
ppx update 兼容校验后更新 ppx-py 与 ppx-js
ppx build 生成当前平台应用和安装包
ppx update --check 和 ppx update --dry-run 不修改环境。兼容更新不会覆盖 api/、gui/src/、ppx/assets/ 或应用数据;不兼容更新会在安装前停止。
ppx icon 接受至少 512×512 的方形 PNG、JPEG 或 WebP 图片,在 ppx/assets/ 原子生成 logo.png、logo.ico 与 logo.icns。DMG 背景图仍由开发者单独维护。
完整文档:PPX 文档
支持 PPX
如果 PPX 帮助你完成了项目,欢迎 Star、提交问题或参与改进。也可以通过以下二维码支持开源维护,感谢每一份支持。
| 微信支付 | 支付宝 |
|---|---|
关注公众号
更多 Python、Web 和桌面开发教程,请关注 潘高陪你学编程。
开源协议
本项目使用 AGPL-3.0-only 协议。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ppx_py-6.0.0.tar.gz.
File metadata
- Download URL: ppx_py-6.0.0.tar.gz
- Upload date:
- Size: 227.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a57ac212f4883e58cba462d5629f686131811a9877f4e9d64e403c2ea84be6c4
|
|
| MD5 |
e8eb313a297bae3c65514673a0f39a85
|
|
| BLAKE2b-256 |
b2e552b17ba1b9557f08fa8649f07824cef6927761eb916487529e7e440c8472
|
Provenance
The following attestation bundles were made for ppx_py-6.0.0.tar.gz:
Publisher:
publish-pypi.yml on pangao1990/PPX
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ppx_py-6.0.0.tar.gz -
Subject digest:
a57ac212f4883e58cba462d5629f686131811a9877f4e9d64e403c2ea84be6c4 - Sigstore transparency entry: 2724737928
- Sigstore integration time:
-
Permalink:
pangao1990/PPX@66ed38d214c701462ca531a3aeaf8054cd2a45f0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pangao1990
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@66ed38d214c701462ca531a3aeaf8054cd2a45f0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ppx_py-6.0.0-py3-none-any.whl.
File metadata
- Download URL: ppx_py-6.0.0-py3-none-any.whl
- Upload date:
- Size: 232.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa4fcf48a8e9b5aa6dfde8a0bd63f6fceb150b649bc1f455c4e481c2710f4a0c
|
|
| MD5 |
96a7dffa7f80c2bae3996c7fc705e1d6
|
|
| BLAKE2b-256 |
25891dc3bafcbca1849c254ac7b08a52a33c32eb60a72f3a7db64ad1a03043e3
|
Provenance
The following attestation bundles were made for ppx_py-6.0.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on pangao1990/PPX
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ppx_py-6.0.0-py3-none-any.whl -
Subject digest:
fa4fcf48a8e9b5aa6dfde8a0bd63f6fceb150b649bc1f455c4e481c2710f4a0c - Sigstore transparency entry: 2724738631
- Sigstore integration time:
-
Permalink:
pangao1990/PPX@66ed38d214c701462ca531a3aeaf8054cd2a45f0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pangao1990
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@66ed38d214c701462ca531a3aeaf8054cd2a45f0 -
Trigger Event:
workflow_dispatch
-
Statement type: