Skip to main content

Python SDK for JadeView - Create desktop applications with WebView

Project description

JadeUI Logo

JadeUI

Python SDK for JadeView - 使用 Web 技术构建桌面应用

PyPI version Python versions


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 通信。

Calculator Demo

Backdrop 效果

展示 Windows 11 Mica/Acrylic 背景效果。

Backdrop Demo

路由示例

使用内置路由系统实现多页面应用。

Router Demo

自定义模板

自定义 CSS 样式的多页面应用示例。

Custom Template Demo

Vue 应用

使用 Vue.js 构建的现代前端应用示例。

Vue App Demo

更多示例请查看 examples 目录。

系统要求

  • 操作系统: Windows 10/11
  • Python: 3.10+
  • 依赖: 无(纯 Python + DLL)

许可证

MIT License

链接

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

jadeui-0.1.2.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

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

jadeui-0.1.2-py3-none-win_amd64.whl (3.4 MB view details)

Uploaded Python 3Windows x86-64

File details

Details for the file jadeui-0.1.2.tar.gz.

File metadata

  • Download URL: jadeui-0.1.2.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

Hashes for jadeui-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4248e6f84fb8de85c76865645a05f1d3e4e7f87baf474f7338b829f971f7e997
MD5 076cc726dbbd2c4b827305c0ab0ca039
BLAKE2b-256 0f54ff34a7e4bfe64ac2e2675dc72a5c5ee7b5941e796f8581844976c7b45f2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for jadeui-0.1.2.tar.gz:

Publisher: publish.yml on HG-ha/Jadeui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jadeui-0.1.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: jadeui-0.1.2-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

Hashes for jadeui-0.1.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 92924e2184420de6cfaf2e5aca707ffa07c986910a06ea96e02f16cb6b3e522d
MD5 fbd898f92ed8834714ad2dfe52a2f5a5
BLAKE2b-256 89eed940977d4bb617d432564f9fb3debcdcbfc791df091ec91da3c125d4b80f

See more details on using hashes here.

Provenance

The following attestation bundles were made for jadeui-0.1.2-py3-none-win_amd64.whl:

Publisher: publish.yml on HG-ha/Jadeui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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