Skip to main content

PawUI

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

运行

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 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 check app.paw    # 仅语法检查
pawui schema           # 输出组件 JSON Schema
pawui render app.paw   # 离屏渲染自检
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.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

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

pawui-0.1.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file pawui-0.1.0.tar.gz.

File metadata

  • Download URL: pawui-0.1.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for pawui-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1159d0f0b1112ff47865f9eda390a47aea789cd62724eef71830dc01611cc667
MD5 a646f3100d9ea83443b39588f29a2c03
BLAKE2b-256 184d13547777ef63006e4caf19f433aa579233ecdf2fdd117a19c673c34c3d19

See more details on using hashes here.

File details

Details for the file pawui-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pawui-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for pawui-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 398bc253bcfbba3af3229c06d90631a4934265fc34552a207afea55d0f395b0f
MD5 cd476ebb599574d41ee79ee2271a97d1
BLAKE2b-256 3b2ae9294f93f8fdb1ab1f41fdbfea6879db9fdf70dbddf71cf8e2358c6f6d11

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

0.1.0.2

2 files

0.1.0.1

2 files

This release

0.1.0 This release

2 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