Skip to main content

PawUI

轻量、直接运行的 Python 声明式 UI 层。HTML 风格,Qt/PySide6 渲染(原生抗锯齿、QSS 圆角/悬停/聚焦、IME 组字正常),无构建。

安装

pip install pawui        # 依赖 PySide6>=6.5,自动安装
python -m pip install --upgrade pawui

运行

pawui app.paw

也可以传统方式启动:

import pawui
pawui.run("app.paw")

语法(HTML 风格)

<Window title="你好" width="460" height="840" theme="dark">
  <Column padding="24" spacing="12">
    <Text size="24" bold>欢迎使用 PawUI 👋</Text>
    <Text size="13" color="subtext">副标题</Text>

    <Text>{$greeting}</Text>

    <Row spacing="8">
      <Button on_click="increment">点我 +1</Button>
      <Button on_click="reset">清空</Button>
    </Row>

    <Input placeholder="输入你的名字..." on_change="on_name"/>
    <Text>你好,{$name}</Text>

    <Card label="点击量" value="{$count}"/>
  </Column>
</Window>

<!-- 自定义组件 -->
<Component name="Card">
  <Column padding="12" bg="surface">
    <Text color="subtext">{$label}</Text>
    <Text size="22" bold>{$value}</Text>
  </Column>
</Component>

<script>
def increment():
    state.count = int(state.get("count", 0)) + 1
</script>

要点

  • 状态绑定:{$count} / {count} / $count,在 <script> 里改 state.count = ... 界面自动刷新。
  • 事件:字符串引用 <script> / main.py 里的函数:on_click="函数名"。
  • 组件:<Component name="X">...</Component> 定义,直接 <X .../> 使用。
  • 主题:theme="dark" | "light",颜色可直接引用:color="subtext"、bg="surface"。
  • 布局:Column 纵排、Row 横排,spacing / padding 调节。

内置组件

Window Column Row Text Button Input Checkbox(开关) Divider Spacer Slider Progress Tabs Image Tooltip TextArea(多行输入) Scroll(可滚动容器) Select(下拉选择) Web(内嵌网页,需要 PySide6-Addons) If(条件渲染) For(列表循环)

<For each="item" in="{$items}">
  <If condition="{$item.done}">
    <Text>{$item.name}</Text>
  </If>
</For>

CLI

pawui run app.paw      # 运行(或直接 pawui app.paw)
pawui watch app.paw    # 热重载:保存即重建窗口
pawui check app.paw    # 仅语法检查
pawui schema           # 输出组件 JSON Schema
pawui render app.paw   # 离屏渲染自检
pawui help             # 列出内置文档主题
pawui help theming     # 查看某篇文档
pawui --version

Metadata

Release files for pawui 0.1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pawui 0.1.2.1
File Size Uploaded
pawui-0.1.2.1.tar.gz 51.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pawui 0.1.2.1
File Interpreter ABI Platform
pawui-0.1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 97.2 kB

Release files / pawui-0.1.2.1.tar.gz

Download URL pawui-0.1.2.1.tar.gz
Size 51.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f6fc6b90d4348398e3bb7bcc1c9f181dfd6d9acc35323f3e210c862609e73c63
BLAKE2b-256 checksum
How to use checksums
34886d55d675261a3d1b26f15e3862edd9c4a9b4df075c86f5a1086f91bca59b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / pawui-0.1.2.1-py3-none-any.whl

Download URL pawui-0.1.2.1-py3-none-any.whl
Size 45.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55f48eb333ade06f5dfbf9d125391b9041a5a77e1caa7dfd76a9a1c9601278c5
BLAKE2b-256 checksum
How to use checksums
6edc0bd91ddc426983fff04a9ccebce1bcd6b13e37e79c49dde5d2a77ce3eded
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

0.1.3

2 release files

This release

0.1.2.1 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page