如何查询maya的textScrollList中的"selected"项?
How to query the "selected" item in maya's textScrollList?
我在 maya 中使用 python,并试图查询 textScrollList 中的 "selected" 项目。在 maya 的文档中,它展示了如何使用 uniqueTag 和 selectUniqueTagItem,我能够正常工作,但它不是我想要的。
在我的 textScrollList 中,它附加了一个包含列表的变量。当我使用 uniqueTag 标志时,它查询的是我分配的 "tag"。我想查询列表中所选项目的内容,而不是标签名称。
例如:
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"。我正在尝试打印该列表中的实际选定项目,而不是该标签名称。谷歌搜索后我似乎找不到示例,任何 help/examples 将不胜感激!太感谢了。
您需要使用select或双击命令,请检查docs它非常清楚。
这是一个可以工作的最小版本
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
我在 maya 中使用 python,并试图查询 textScrollList 中的 "selected" 项目。在 maya 的文档中,它展示了如何使用 uniqueTag 和 selectUniqueTagItem,我能够正常工作,但它不是我想要的。
在我的 textScrollList 中,它附加了一个包含列表的变量。当我使用 uniqueTag 标志时,它查询的是我分配的 "tag"。我想查询列表中所选项目的内容,而不是标签名称。
例如:
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"。我正在尝试打印该列表中的实际选定项目,而不是该标签名称。谷歌搜索后我似乎找不到示例,任何 help/examples 将不胜感激!太感谢了。
您需要使用select或双击命令,请检查docs它非常清楚。
这是一个可以工作的最小版本
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