Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 intField不显示更改_Python 2.7_Maya - Fatal编程技术网

Python 2.7 intField不显示更改

Python 2.7 intField不显示更改,python-2.7,maya,Python 2.7,Maya,我正在编写一个脚本,以简化使用Vray时的繁琐任务,但我一直使用intFields,这些intFields应该允许用户在按下按钮时键入一个触发特定操作的int值。我将代码简化为只包含必要的部分。无论我将值更改为什么,脚本编辑器输出中的值始终为0 import maya.cmds as cmds idManagerUI = cmds.window(title='Vray ID Manager', s = False, wh = (300,500)) cmds.columnLayout(adj

我正在编写一个脚本,以简化使用Vray时的繁琐任务,但我一直使用intFields,这些intFields应该允许用户在按下按钮时键入一个触发特定操作的int值。我将代码简化为只包含必要的部分。无论我将值更改为什么,脚本编辑器输出中的值始终为0

import maya.cmds as cmds

idManagerUI = cmds.window(title='Vray ID Manager', s = False, wh = (300,500))

cmds.columnLayout(adj = True)

cmds.text (l = 'type in MultimatteID to select matching shaders \n or specify ObjectID to select matching objects \n __________________________________________ \n')

cmds.text (l = 'MultimatteID: \n')
cmds.intField( "MultimatteID", editable = True)
MultimatteIdButton = cmds.button(l = 'Go!', w = 30, h = 50, c = 'multimatteChecker()')
cmds.text (l = '\n')

cmds.showWindow(idManagerUI)

MultimatteIdInput = cmds.intField( "MultimatteID", q = True, v = True)


def multimatteChecker():
    print MultimatteIdInput
三件事:

首先,在编写时,您无法确定intField
MultimatteID
是否实际获得了您认为应该具有的名称。Maya小部件名称是唯一的,就像Maya对象名称一样——您可以将其命名为
MultimatteID
,但实际上会返回一个名为
MultimatteID2
的小部件,因为您在某个地方有一个未删除的窗口(可见或不可见),该窗口具有类似的控件名称

其次,粘贴的代码在创建窗口后立即查询控件的值。它应该总是打印出你在创作时给它的价值

最后--不要在按钮中使用命令分配的字符串版本。从侦听器中的代码转移到工作脚本时,这是不可靠的

这应该满足您的要求:

    idManagerUI = cmds.window(title='Vray ID Manager', s = False, wh = (300,500))
    cmds.columnLayout(adj = True)
    cmds.text (l = 'type in MultimatteID to select matching shaders \n or specify ObjectID to select matching objects \n __________________________________________ \n')
    cmds.text (l = 'MultimatteID: \n')
    # store the intField name
    intfield = cmds.intField( "MultimatteID", editable = True)
    cmds.text (l = '\n')

    # define the function before assigning it. 
    # at this point in the code it knows what 'intfield' is....
    def multimatteChecker(_):
        print cmds.intField( intfield, q = True, v = True)

    #assign using the function object directly
    MultimatteIdButton = cmds.button(l = 'Go!', w = 30, h = 50, c = multimatteChecker)