Add menu to grapheditor/hypershape

37 views
Skip to first unread message

Pritish Dogra

unread,
Nov 24, 2017, 3:35:05 PM11/24/17
to Python Programming for Autodesk Maya
I can add the menu through the following code

import pymel.core as pm
parent_object
= pm.getPanel(sty="graphEditor")[0]
pm
.menu("test_menu", parent=parent_object, label="Test Menu", tearOff=True

However as soon as I tear off the graph editor panel, I lose the menu. How can I make this permanent for the graph editor window or any other scripted panel?

Cheers

Pritish






Justin Israel

unread,
Nov 26, 2017, 8:13:17 PM11/26/17
to python_in...@googlegroups.com
I haven't been setting this stuff up in newer Maya releases (2016+) so my information may be out of date. But ya it is a bit tricky to make custom changes to Maya's interface and have them be persistent when the UI is modified. This is happening because a tear-off is recreating the widget and your injected modifications to the old widget are lost. 

Some options you have to automatically introduce this change is to include setting an event filter on one of the parent objects that don't change. This could end up just being the main window or the QApplication. The event filter would be watching for the ChildAdded event, and if its the expected type of widget you can apply your customization. 
 
I don't recall the MMessage API offering any hooks for when arbitrary UI's are created.  


Cheers

Pritish






--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/08d0a77a-a497-460e-8c69-9ef5e8231a7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert White

unread,
Nov 27, 2017, 11:22:32 AM11/27/17
to Python Programming for Autodesk Maya
Yeah, there isn't an API call for when UI's are created, just destroyed.



On Sunday, November 26, 2017 at 7:13:17 PM UTC-6, Justin Israel wrote:
On Sat, Nov 25, 2017 at 9:35 AM Pritish Dogra <pritis...@gmail.com> wrote:
I can add the menu through the following code

import pymel.core as pm
parent_object
= pm.getPanel(sty="graphEditor")[0]
pm
.menu("test_menu", parent=parent_object, label="Test Menu", tearOff=True

However as soon as I tear off the graph editor panel, I lose the menu. How can I make this permanent for the graph editor window or any other scripted panel?

I haven't been setting this stuff up in newer Maya releases (2016+) so my information may be out of date. But ya it is a bit tricky to make custom changes to Maya's interface and have them be persistent when the UI is modified. This is happening because a tear-off is recreating the widget and your injected modifications to the old widget are lost. 

Some options you have to automatically introduce this change is to include setting an event filter on one of the parent objects that don't change. This could end up just being the main window or the QApplication. The event filter would be watching for the ChildAdded event, and if its the expected type of widget you can apply your customization. 
 
I don't recall the MMessage API offering any hooks for when arbitrary UI's are created.  


Cheers

Pritish






--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages