python - 对象名称“testUI”不是唯一的
问题描述
在下面执行此代码时,将在运行代码的第一个实例上创建窗口。如果我尝试编辑方法 createCustomUI... 会出现问题。
我收到以下错误
错误:第 1 行:对象的名称“testUI”不是唯一的。
....并且没有创建窗口。我试图找出为什么会出现这个错误并找到一个好的解决方案。
import pymel.core as pm
from functools import partial
class ControlCurveTools_UI(object):
def __init__(self):
self.windowName = "testUI"
self.windowHeight = 1000
self.windowWidth = 250
self.createUI(self.windowName, self.windowHeight, self.windowWidth, True, False)
def createUI(self, windowName, windowHeight, windowWidth, dock, scroll):
if dock == True:
if pm.dockControl(windowName + "_dock", exists = True):
pm.deleteUI(windowName + "_dock")
else:
if pm.window(windowName, exists = True):
pm.deleteUI(windowName)
print "here"
print self.windowName
self.window = pm.window(windowName, title = windowName, w = windowWidth, h = windowHeight, mnb = False, mxb = False)
print "here2"
self.mainlayout = pm.columnLayout(adj = True)
# Uniqe UI stuff
self.createCustomUI()
print "here3"
if dock == True:
pm.dockControl(windowName + "_dock", label = windowName + "_dock", area = "left", content = self.window, w = self.windowWidth)
else:
pm.showWindow(self.window)
def createCustomUI(self):
pm.rowColumnLayout(nc = 1, parent = self.mainlayout, w = self.windowWidth, e=1)
pm.button(label = "Replace Curve With Selected", p=self.mainlayout)
pm.button(label = "Mirror Selected Curve", p=self.mainlayout)
# print "creatingCustomUI"
解决方案
您使用 dock=True 调用您的构建方法,因此本节:
if dock == True:
if pm.dockControl(windowName + "_dock", exists = True):
pm.deleteUI(windowName + "_dock")
else:
if pm.window(windowName, exists = True):
pm.deleteUI(windowName)
不会删除窗口,因为没有执行 else 语句。
推荐阅读
- azure - 确定 Microsoft Azure 中的虚拟机状态和活动
- google-chrome - 调试three.js时如何在断点处查看纹理的实际图像?
- solr - Solr 和时间码信息
- awk - 如何使用 sed 替换多行中的单词?
- css - 更改猫头鹰轮播图像的颜色
- azure - 使用 Azure API 管理和 Function App 作为后端来管理授权
- javascript - Vuetify:复选框在未选中时显示状态已选中,反之亦然
- angular - 在 Angular 中获取订阅之外的结果
- oracle - 存储过程将选择哪个 NLS_DATE_FORMAT
- web-applications - Java Spring Boot 相关会话超时