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(可滚动容器) 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pawui-0.1.1.tar.gz
(47.3 kB
view details)
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
pawui-0.1.1-py3-none-any.whl
(43.1 kB
view details)
File details
Details for the file pawui-0.1.1.tar.gz.
File metadata
- Download URL: pawui-0.1.1.tar.gz
- Upload date:
- Size: 47.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f7171c1965200a32f90a81ac50e0e64b7a59dce8cc7f125fa3500c3060efb17
|
|
| MD5 |
12d0dc610e30f9cade51730497e4400c
|
|
| BLAKE2b-256 |
f77232da8bebf21800fc20efcb14d116cc05c3926f4e758004ac66f928160a2c
|
File details
Details for the file pawui-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pawui-0.1.1-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
129b1ad5bad3d299903beadcff1b91abc3aaf435abdec86faf4b587b55eda710
|
|
| MD5 |
dd4d46a4f584ecea5ac432c387d651c7
|
|
| BLAKE2b-256 |
9be6ebd59ac90f136f2cc9cc44ae64a5c855eb7c11d63ca306b00ffdbbea7f5e
|