【问题标题】:object name "testUI" is not unique对象名称“testUI”不是唯一的
【发布时间】:2019-01-10 19:44:30
【问题描述】:

在执行下面的代码时,窗口是在运行代码的第一个实例上创建的。如果我尝试编辑方法 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"

【问题讨论】:

  • 搜索“对象的名称不是唯一的”并且有很多命中。研究一下,如果没有帮助,edit这个问题并告诉我们你做了什么。

标签: python oop user-interface maya


【解决方案1】:

您使用 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 语句。

【讨论】:

    猜你喜欢
    • 2021-09-21
    • 2023-01-10
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多