I'd like to add some new buttons to the Maya Graph editor -- particularly on top of the Channel list with all the attributes in the left of the window. However I'd rather not muck around with the Maya Startup scripts for the Graph Editor itself. Is there a way to "parent" the new buttons I want inside every new Graph Editor window using a separate script?
Ideally this could be all Python.
TL;DR;
There are two really usefull things to know when it comes to editing Maya's UI.
First thing is the
History -> Echo all commands
checkbox in your script editor. This can print out a lot of garbage with usefull pieces of information inside.Second thing is the
whatIs
command (Doc).This combination will allow you to track down how and where the graph editor is created. Now let's do it.
1: Open the graph editor
Window -> Animation Editors -> Graph Editor
GraphEditor;
is a Run Time Command which executestearOffPanel "Graph Editor" "graphEditor" true;
when called. That's why it appears in the script editor.2: Run
whatIs "tearOffPanel";
(mel)With a little investigation in this file, you can deduce that you can create a whole new Graph Editor using the
scriptedPanel
command.3: Create your own Graph Panel
The scriptedPanel doc show you how to create a scripted panel and include it in a window. You can now create you custom graph editor using this:
4: Try to understand how the Graph Editor is built
This script will print out the widget hierarchy of a Graph Editor (create your custom Graph Editor first):
Also, you can check into
C:\Program Files\Autodesk\Maya2014\scripts\others\graphEditorPanel.mel
,@939: global proc addGraphEditor (string $whichPanel)
You can now realize that a lot of widgets are not given any name, only default name given by Maya. Hence, we can't add widgets and parent them using a full path because this path will change every time a new Graph Editor is created.
The item we will try to rely on is
GE_ui_scriptedPanelOutlineEdForm
which is aformLayout
containing an otherformLayout
and apaneLayout
.5: Create your buttons and reorder the content of
GE_ui_scriptedPanelOutlineEdForm
To that, you may have to go with PySide/PyQt. Find the pointer of the graph editor and find how the elements are layouted.
Here is a sample about changing stylesheet of maya menu :
And here sonme experiments about channelBox :
You can do this kingd of experiments with all maya widget (find the pointer and then use wrapInstance to get the QT pointer, then iterate throught children to find the layout you may want)
hope it helps