Python SDK for JadeView - Create desktop applications with WebView
Project description
JadeUI
Python SDK for JadeView - 使用 Web 技术构建桌面应用
JadeUI 是 JadeView 的 Python SDK,让你可以使用 Python + Web 技术构建现代桌面应用程序。
特性
- WebView 窗口 - 使用 HTML/CSS/JS 构建 UI
- 现代外观 - 支持 Windows 11 Mica/Acrylic 效果
- 主题切换 - Light/Dark/System 主题
- IPC 通信 - Python 与前端双向通信
- 打包体积 - 极小的依赖,打包后体积仅有8MB左右
安装
pip install jadeui
快速开始
from jadeui import JadeUIApp, Window
app = JadeUIApp()
app.initialize() # 可选参数见下方
@app.on_ready
def on_ready():
window = Window(
title="Hello JadeUI",
width=800,
height=600,
url="https://example.com"
)
window.show()
app.run()
初始化选项
app.initialize(
enable_dev_tools=True, # 启用开发者工具 (F12)
log_file="./app.log", # 日志文件路径
data_directory="./data", # WebView 数据目录,否则在当前目录解压资源
)
完整示例
加载本地 HTML
from jadeui import JadeUIApp, Window, LocalServer
app = JadeUIApp()
server = LocalServer()
@app.on_ready
def on_ready():
url = server.start("./web", "myapp")
window = Window(
title="My App",
width=1024,
height=768,
url=f"{url}/index.html",
remove_titlebar=True, # 无边框窗口
transparent=True,
)
window.show()
window.set_backdrop("mica") # Windows 11 效果
app.run()
IPC 通信
from jadeui import JadeUIApp, Window, IPCManager
app = JadeUIApp()
ipc = IPCManager()
# 注册消息处理器
@ipc.on("message")
def handle_message(window_id, message):
print(f"收到: {message}")
ipc.send(window_id, "reply", f"Echo: {message}")
return 1
@app.on_ready
def on_ready():
Window(title="IPC Demo", url="...").show()
app.run()
前端 JavaScript:
// 发送消息到 Python (使用 jade.ipcSend)
jade.ipcSend("message", "Hello from JS!");
// 接收 Python 消息 (使用 jade.ipcMain)
jade.ipcMain("reply", function(data) {
console.log("Python replied:", data);
});
窗口选项
window = Window(
title="My App",
width=1024,
height=768,
url="https://example.com",
# 外观
remove_titlebar=True, # 移除标题栏
transparent=True, # 透明背景
theme="Dark", # Light/Dark/System
# 大小限制
min_width=800,
min_height=600,
max_width=1920,
max_height=1080,
resizable=True,
# 位置
x=100, # -1 为居中
y=100,
# 状态
maximized=False,
fullscreen=False,
always_on_top=False,
# WebView
autoplay=False,
disable_right_click=False,
user_agent="Custom UA",
)
窗口方法
# 显示/隐藏
window.show()
window.hide()
window.close()
# 状态
window.minimize()
window.maximize()
window.restore()
window.focus()
window.set_fullscreen(True)
# 属性
window.set_title("New Title")
window.set_size(1280, 720)
window.set_position(100, 100)
window.center()
window.set_always_on_top(True)
# 主题
window.set_theme("Dark")
window.set_backdrop("mica") # none/mica/mica_alt/acrylic/tabbed
# WebView
window.load_url("https://example.com")
window.execute_js("console.log('Hello!')")
# 状态查询
window.is_visible
window.is_maximized
window.is_minimized
window.is_focused
API 文档
完整文档请访问: https://jade.run/python-sdk
示例效果
计算器
简单的计算器示例,展示基本的窗口和 IPC 通信。
Backdrop 效果
展示 Windows 11 Mica/Acrylic 背景效果。
路由示例
使用内置路由系统实现多页面应用。
自定义模板
自定义 CSS 样式的多页面应用示例。
Vue 应用
使用 Vue.js 构建的现代前端应用示例。
更多示例请查看 examples 目录。
系统要求
- 操作系统: Windows 10/11
- Python: 3.10+
- 依赖: 无(纯 Python + DLL)
许可证
MIT License
链接
Project details
Release history Release notifications | RSS feed
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 jadeui-0.1.1.tar.gz.
File metadata
- Download URL: jadeui-0.1.1.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
805517247d6445a19891df48355f0395f13cf77f0b6679ce0b95581a0ea27a0f
|
|
| MD5 |
a7d6f1e7e1f8ce06d25c55cfef166b57
|
|
| BLAKE2b-256 |
778102c45b16593b2fdc7626daa8bb1a3d2e5e0dfe365efd14709c14011b2d93
|
Provenance
The following attestation bundles were made for jadeui-0.1.1.tar.gz:
Publisher:
publish.yml on HG-ha/Jadeui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jadeui-0.1.1.tar.gz -
Subject digest:
805517247d6445a19891df48355f0395f13cf77f0b6679ce0b95581a0ea27a0f - Sigstore transparency entry: 805022176
- Sigstore integration time:
-
Permalink:
HG-ha/Jadeui@2566a3a1f70925555aacb1b3fcfd9e86d4655441 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/HG-ha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2566a3a1f70925555aacb1b3fcfd9e86d4655441 -
Trigger Event:
push
-
Statement type:
File details
Details for the file jadeui-0.1.1-py3-none-win_amd64.whl.
File metadata
- Download URL: jadeui-0.1.1-py3-none-win_amd64.whl
- Upload date:
- Size: 3.4 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfa8e8602e79e2e4f97b5db717229b5c5b92ae0c144549e9865f4f44d060947d
|
|
| MD5 |
8cf81b14be930bdbf5f9decd159354f8
|
|
| BLAKE2b-256 |
8892d23fba7bc64febfa23013e7277905ce846295d7be99d7c6aaccc41f7d032
|
Provenance
The following attestation bundles were made for jadeui-0.1.1-py3-none-win_amd64.whl:
Publisher:
publish.yml on HG-ha/Jadeui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jadeui-0.1.1-py3-none-win_amd64.whl -
Subject digest:
bfa8e8602e79e2e4f97b5db717229b5c5b92ae0c144549e9865f4f44d060947d - Sigstore transparency entry: 805022186
- Sigstore integration time:
-
Permalink:
HG-ha/Jadeui@2566a3a1f70925555aacb1b3fcfd9e86d4655441 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/HG-ha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2566a3a1f70925555aacb1b3fcfd9e86d4655441 -
Trigger Event:
push
-
Statement type: