Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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 如何查询maya textScrollList中的“选定”项?_Python_User Interface_Maya - Fatal编程技术网

Python 如何查询maya textScrollList中的“选定”项?

Python 如何查询maya textScrollList中的“选定”项?,python,user-interface,maya,Python,User Interface,Maya,我正在maya中使用python,并尝试查询textScrollList中的选定项。在maya的文档中,它显示了如何使用uniqueTag和selectUniqueTagItem,我能够正常工作,但这不是我想要的 在我的textScrollList中,它附加了一个包含列表的变量。当我使用uniqueTag标志时,它是我指定的标记。我想查询列表中所选项目的内容,而不是标记名 例如: tScrollList = cmds.textScrollList( numberOfRows=8, allowMu

我正在maya中使用python,并尝试查询textScrollList中的选定项。在maya的文档中,它显示了如何使用uniqueTag和selectUniqueTagItem,我能够正常工作,但这不是我想要的

在我的textScrollList中,它附加了一个包含列表的变量。当我使用uniqueTag标志时,它是我指定的标记。我想查询列表中所选项目的内容,而不是标记名

例如:

tScrollList = cmds.textScrollList( numberOfRows=8, allowMultiSelection=False,
        append=fileList, showIndexedItem=4, dcc=('doubleClick()') )



def refreshGUI():

    cmds.textScrollList(tScrollList, edit=True, removeAll=True) #removes current list
    newList = searchInput() #this contains a list

    #repopulates list 
    for r in newList:
        cmds.textScrollList(tScrollList, edit=True, append=r, uniqueTag="selectedFile", dcc=('doubleClick()')) 



def doubleClick():

    cmds.textScrollList(tScrollList, edit=True, selectUniqueTagItem=["selectedFile"])

    clickList = cmds.textScrollList(tScrollList, query=True, selectUniqueTagItem= True)   
    print clickList

在我的gui中双击该项时,此示例将打印selectedFile。我正在尝试打印该列表中实际选定的项目,而不是该标记名。在谷歌搜索之后,我似乎找不到示例,任何帮助/示例都将不胜感激!非常感谢你

您需要使用select或双击命令,请检查该命令,这一点非常清楚

这是一个工作的最低版本

import maya.cmds as cmds

cmds.window()
cmds.paneLayout()
fooBar = cmds.textScrollList( numberOfRows=8, allowMultiSelection=True,
            append=['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',
                    'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen'],
            selectItem='six', showIndexedItem=4, dcc = "getSelected()")
cmds.showWindow()

def getSelected():
    someList = cmds.textScrollList(fooBar, q=1, si=1)
    print someList

嗨,阿卡扬,谢谢你的回复。我确实使用了双击命令,它位于我的第一个文本滚动列表的第二行,它指向我的双击功能。但是我注意到你没有使用uniqueTag标志。。。我会试一试,看看是否管用。管用!!删除uniqueTag标志并简单地将selectItem标志添加为True,使其返回在列表中选择的确切项目。非常感谢。但是,如果textScrollList对象包装在类中而不是模块级范围中,该怎么办呢。