Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.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 如何使用PySide将新按钮设置为Maya中通道盒的父级?_Python_Pyqt_Pyside_Maya - Fatal编程技术网

Python 如何使用PySide将新按钮设置为Maya中通道盒的父级?

Python 如何使用PySide将新按钮设置为Maya中通道盒的父级?,python,pyqt,pyside,maya,Python,Pyqt,Pyside,Maya,我对PySide有一个非常基本的了解。我希望为现有的频道盒添加一个按钮。但是,除了获取Maya主窗口外,我不确定从何处开始。(但我甚至不确定这是否正确): 搞乱Maya的UI可能是一项困难的任务,有两种方法可以做到这一点。 首先是使用maya.cmds将小部件添加到maya的UI中。第二个是像您所做的那样,在Qt类中包装一个Maya小部件 这是一个类似的问题: 我只回答了maya.cmdscode,还有一个答案可能会让您感兴趣,那就是使用PySide 以下是一个解决方案: nbIteration

我对PySide有一个非常基本的了解。我希望为现有的频道盒添加一个按钮。但是,除了获取Maya主窗口外,我不确定从何处开始。(但我甚至不确定这是否正确):


搞乱Maya的UI可能是一项困难的任务,有两种方法可以做到这一点。 首先是使用
maya.cmds
将小部件添加到maya的UI中。第二个是像您所做的那样,在Qt类中包装一个Maya小部件

这是一个类似的问题: 我只回答了
maya.cmds
code,还有一个答案可能会让您感兴趣,那就是使用PySide

以下是一个解决方案:

nbIteration = 0
def getChildren(uiItem, nbIteration):
    for childItem in cmds.layout(uiItem, query=True, childArray=True):
        try:
            print "|___"*nbIteration + childItem
            getChildren(uiItem + "|" + childItem, nbIteration+1)
        except:
            pass
getChildren("MayaWindow|MainChannelsLayersLayout", nbIteration)
如果您运行此代码,这将为您提供
通道盒/层编辑器中包含的小部件的名称

ChannelButtonForm <-- This is the form containing the 3 buttons on the top-right 
|___cbManipsButton
|___cbSpeedButton
|___cbHyperbolicButton
ChannelsLayersPaneLayout <-- This is the layout containing the channel box and the layer editor. A paneLayout has a splitter to resize his childrens.
|___ChannelBoxForm 
|___|___menuBarLayout1 
|___|___|___frameLayout1
|___|___|___|___mainChannelBox
|___LayerEditorForm
|___|___DisplayLayerUITabLayout
|___|___|___DisplayLayerTab
|___|___|___|___formLayout3

由于您没有告诉我们要将按钮放置在何处,如果您想要更合适的位置,则必须编辑您的问题。

搞乱Maya的UI可能是一项困难的任务,有两种方法可以做到这一点。 首先是使用
maya.cmds
将小部件添加到maya的UI中。第二个是像您所做的那样,在Qt类中包装一个Maya小部件

这是一个类似的问题: 我只回答了
maya.cmds
code,还有一个答案可能会让您感兴趣,那就是使用PySide

以下是一个解决方案:

nbIteration = 0
def getChildren(uiItem, nbIteration):
    for childItem in cmds.layout(uiItem, query=True, childArray=True):
        try:
            print "|___"*nbIteration + childItem
            getChildren(uiItem + "|" + childItem, nbIteration+1)
        except:
            pass
getChildren("MayaWindow|MainChannelsLayersLayout", nbIteration)
如果您运行此代码,这将为您提供
通道盒/层编辑器中包含的小部件的名称

ChannelButtonForm <-- This is the form containing the 3 buttons on the top-right 
|___cbManipsButton
|___cbSpeedButton
|___cbHyperbolicButton
ChannelsLayersPaneLayout <-- This is the layout containing the channel box and the layer editor. A paneLayout has a splitter to resize his childrens.
|___ChannelBoxForm 
|___|___menuBarLayout1 
|___|___|___frameLayout1
|___|___|___|___mainChannelBox
|___LayerEditorForm
|___|___DisplayLayerUITabLayout
|___|___|___DisplayLayerTab
|___|___|___|___formLayout3

由于您没有告诉我们要将按钮放置在何处,如果您想要更合适的位置,您必须编辑您的问题。

只需一个按钮?您希望按钮显示在哪里?在通道盒的顶部,或者在边缘的某个地方?只有一个按钮?您希望按钮显示在哪里?在通道盒的顶部,或者在边缘的某个地方?这太棒了。非常感谢。我还尝试在“曲线图编辑器”(Graph Editor)和“大纲视图”(Outliner)中创建一个按钮的父级。使用上述命令作为
getChildren(“graphEditor1Window |”,nbIteration)
似乎不起作用。它说它找不到图形编辑器,尽管
cmds.lsUI
说它存在。请尝试以下操作:
getChildren(“graphEditor1Window | tearofpane”,nbIteration)
您需要将布局传递给
getChildren
函数。对于大纲视图:
getChildren(“SequenceeditorPanelWindow | tearofpane”,nbIteration)
谢谢@DrHaze!这里有一个我没有想到的问题:在当前的设置中,窗口必须已经存在,才能将新的UI按钮等插入其中一个窗体。在创建新的GrapherEditor窗口时,插入按钮的最佳方法是什么?作为简短的回答,我在这里看到两种解决方案。首先是编写一个脚本,创建一个自定义的图形编辑器,如我在链接问题中的答案所示。您必须调用此脚本,而不是进入
窗口->动画编辑器->图形编辑器
。第二种解决方案是有风险的,我建议您对正在修改的任何文件进行备份。您可以直接编辑此文件
C:\Program Files\Autodesk\Maya2014\scripts\others\graphieditorpanel.mel
,此功能尤其是
addgraphieditor
,用于向曲线图编辑器添加按钮。这非常棒。非常感谢。我还尝试在“曲线图编辑器”(Graph Editor)和“大纲视图”(Outliner)中创建一个按钮的父级。使用上述命令作为
getChildren(“graphEditor1Window |”,nbIteration)
似乎不起作用。它说它找不到图形编辑器,尽管
cmds.lsUI
说它存在。请尝试以下操作:
getChildren(“graphEditor1Window | tearofpane”,nbIteration)
您需要将布局传递给
getChildren
函数。对于大纲视图:
getChildren(“SequenceeditorPanelWindow | tearofpane”,nbIteration)
谢谢@DrHaze!这里有一个我没有想到的问题:在当前的设置中,窗口必须已经存在,才能将新的UI按钮等插入其中一个窗体。在创建新的GrapherEditor窗口时,插入按钮的最佳方法是什么?作为简短的回答,我在这里看到两种解决方案。首先是编写一个脚本,创建一个自定义的图形编辑器,如我在链接问题中的答案所示。您必须调用此脚本,而不是进入
窗口->动画编辑器->图形编辑器
。第二种解决方案是有风险的,我建议您对正在修改的任何文件进行备份。您可以直接编辑此文件
C:\Program Files\Autodesk\Maya2014\scripts\others\graphieditorpanel.mel
,尤其是此功能
addgraphieditor
,以向曲线图编辑器添加按钮。