Skip to content

cpcgskill/cpform

Repository files navigation

CPForm

CPForm:面向 DCC 工具开发的声明式 PyQt / PySide UI 库。一次开发,原生 / Maya / 3ds Max 多端兼容+统一样式。
版本兼容Maya 2018 - 2026 3ds Max 2018 - 2026 Python 2.7 - 3.x PyQt5-6 / PySide2-6

目录

功能介绍

  1. 跨软件代码兼容,包括Maya、3ds Max、还有原生环境。
  2. 全局统一样式,各个软件以及各个版本下一致的UI与行为
  3. 全局可配置,可以所以调整主题色、背景色等各个参数。
  4. 声明式写法,便于构建UI以及布局。
  5. 表单提交功能,便于收集输入的数据。

快速开始

安装

  • CPForm 目前尚未发布到 PyPI,但你可以通过以下步骤从源代码安装:
git clone git@github.com:cpcgskill/cpform.git
cd cpform
  • 或者直接从 GitHub 下载源代码压缩包并解压。

下载

测试

CPForm 提供了一个简单的测试脚本,可以通过以下命令运行:

python3 ./scripts/cpform_test/core.py # python3 可能需要替换为你自己的 Python 路径

使用教程

Native

这里以PySide2+Python3为例,其他版本的PyQt/PySide使用方法类似。

from PySide2.QtWidgets import *
import sys

app = QApplication(sys.argv)

from cpform.widget.core import *
import cpform.docker as docker


def show():
    ui = ScrollArea(
        VBoxLayout(
            childs=[
                Label('Label'),
                PrimaryButton(text='PrimaryButton'),
                AttentionButton(text='AttentionButton'),
                SuccessButton(text='SuccessButton'),
                WarningButton(text='WarningButton'),
                ErrorButton(text='ErrorButton'),
                NormalButton(text='Button'),
            ],
            align='top'
        )
    )
    docker.default_docker(title='Native Example', form=ui)


show()
app.exec_()

Maya

CPForm 在 Maya 中的使用方法与 Native 类似,但在maya中启动时无需创建 QApplication 实例。你可以直接在 Maya 的 Python 脚本编辑器中运行以下代码:

from cpform.widget.core import *
import cpform.docker as docker


def show():
    ui = ScrollArea(
        VBoxLayout(
            childs=[
                Label('Label'),
                PrimaryButton(text='PrimaryButton'),
                AttentionButton(text='AttentionButton'),
                SuccessButton(text='SuccessButton'),
                WarningButton(text='WarningButton'),
                ErrorButton(text='ErrorButton'),
                NormalButton(text='Button'),
            ],
            align='top'
        )
    )
    docker.default_docker(title='Maya Example', form=ui)


show()
  • 注意:在 Maya 中使用 CPForm 时,请确保CPForm下的src目录已添加到 Maya 的 Python 路径中。
  • 或者将src下的所有文件复制到 Maya 的 Python 脚本目录中。 添加路径

3ds-Max

todo, CPForm 会自动完成代码的兼容,所以在 3ds Max 中的使用方法与 Maya 类似。只需要注意将其添加到 3ds Max 的 Python 路径中即可。

引用

LLM 快速参考

你可以查看项目根目录下的 llms.txt 文件,它为大语言模型提供:

  • 精简的 API/组件及布局清单
  • 数据收集与 read_data() 机制说明
  • 主题配置 (config_manager) 与自定义指南
  • 典型使用模式(窗口 / 弹出 / 表单提交)

将 llms.txt 作为提示上下文,可显著减少模型推断时间并提升回答准确性。

版权说明

该项目签署了Apache-2.0 授权许可,详情请参阅 LICENSE

About

CPForm 是一个声明式的 PyQt/PySide 界面库,旨在简化 PyQt/PySide 的界面开发并提供样式一致与平台兼容

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors