This commit is contained in:
2025-11-24 21:05:22 +08:00
parent e76152945e
commit e4c713035b
12 changed files with 585 additions and 414 deletions

View File

@@ -10,6 +10,24 @@ Animation picker for Autodesk Maya 2017 (or higher)
> A menus, markmenu and hotbox designer cross DCC.
> https://github.com/luckylyk/hotbox_designer
## 🔧 版本兼容性
### 支持的 Maya 版本
- **Maya 2017-2024** - 使用 PySide2
- **Maya 2025+** - 使用 PySide6
- **自动适配** - 运行时自动检测 Maya 版本并使用对应的 Qt 绑定
### Qt 兼容性
- **PySide2** - Maya 2017-2024自动
- **PySide6** - Maya 2025+(自动)
- **Python 2/3** - 完全兼容
### 兼容性特性
1. **自动 Qt 检测** - 根据 Maya 版本自动选择 PySide2 或 PySide6
2. **API 映射** - PySide6 API 自动映射到 PySide2 兼容接口
3. **向后兼容** - 支持旧版本 picker 文件的自动升级
4. **跨版本数据** - Picker 文件在不同 Maya 版本间通用
## 功能特性
- 简单快速的 picker 创建
@@ -57,6 +75,33 @@ animation_tools.dwpicker.show(ignore_scene_pickers=True)
5. **代码执行模板**`import dwpicker``import animation_tools.dwpicker as dwpicker`
6. 保持所有原始功能不变
## 💡 技术架构
### 核心模块
- **main.py** - 主窗口和核心逻辑
- **picker.py** - Picker 画布和交互
- **designer/** - Picker 设计器模块
- **pyside.py** - Qt 版本兼容层
- **compatibility.py** - 数据格式兼容性处理
### 兼容性层次
```
┌─────────────────────────────┐
│ DwPicker UI │
└──────────┬──────────────────┘
┌──────────▼──────────────────┐
│ pyside.py (兼容层) │
│ - PySide6 (Maya 2025+) │
│ - PySide2 (Maya 2017-2024) │
└──────────┬──────────────────┘
┌──────────▼──────────────────┐
│ Maya API │
│ - maya.cmds │
└─────────────────────────────┘
```
## 官方文档
更多信息请访问 [Official Documentation](https://dreamwall-animation.github.io/dwpicker)

View File

@@ -1,16 +1,31 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
PySide Compatibility Module
自动检测并导入合适的 Qt 绑定PySide2 或 PySide6
支持 Maya 2017-2026+ 所有版本
"""
try:
ModuleNotFoundError
except NameError:
class ModuleNotFoundError(ImportError): # Python2 backward compatilibity
# Python 2 backward compatibility
class ModuleNotFoundError(ImportError):
pass
from maya import cmds
# 尝试导入 PySide6Maya 2025+
try:
if int(cmds.about(majorVersion=True)) >= 2025:
maya_version = int(cmds.about(majorVersion=True))
if maya_version >= 2025:
print(f"DwPicker: Detected Maya {maya_version}, using PySide6")
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6 import __version__
import shiboken6 as shiboken2
# PySide6 兼容性映射
QtWidgets.QShortcut = QtGui.QShortcut
QtWidgets.QAction = QtGui.QAction
@@ -21,7 +36,15 @@ try:
QtCore.Qt.BackgroundColorRole = QtCore.Qt.BackgroundRole
else:
raise TypeError()
except (ModuleNotFoundError, TypeError):
# Maya 2017-2024 使用 PySide2
raise TypeError("Maya version < 2025, will use PySide2")
except (ModuleNotFoundError, TypeError, ImportError) as e:
# 降级到 PySide2Maya 2017-2024
try:
maya_version = int(cmds.about(majorVersion=True))
print(f"DwPicker: Detected Maya {maya_version}, using PySide2")
except:
print("DwPicker: Using PySide2")
from PySide2 import QtCore, QtGui, QtWidgets
import shiboken2