(UI) Highlight menu items [with green brackets]

Hi,

Is it possible to highlight custom menu items with those green brackets?image

Yes, you can get QMenu items and dump them for inspection. Did some to custom color menu items in the node editor fiddling around with it. The dump will however be a huge trove of “QMenuItems##” and so on so to find the correct one might be a pain using the same method I used. If you add the menu items yourself with Qt you should however know how to access your items.

Damn.

I was hoping to do that without QT as I don’t have any experience with that.

Anyway, Thank you!

Found the python tab I had the code in when I looked into this, maybe it could help.

import pymel.core as pm      


def recursive_children(qt_object, level=0):
    
    print '  ' * level + type(qt_object).__name__    
    children = qt_object.children()
    
    for child in children:        
        recursive_children(child, level)    
        level += 1
        

def widget_parser(widget):
    """ Recursive listing of a widgets structure, """
    children = widget.children()
    
    for child in children:
        
        print type(child).__name__
    
    
# Get the node editor as a Qt object,
node_editor = pm.getPanel(scriptType='nodeEditorPanel')[0]
node_editor_qt = node_editor.asQtObject()

widget_parser(node_editor_qt)
recursive_children(node_editor_qt)

Probably the easiest way to do this is just use the version flag on cmds.menuItem, if the version value == the current running version of Maya, it will highlight. Otherwise it won’t.

If you’re using mel, and maya LT, you need to use ltVersion instead.

2 Likes

wow. appreciate the code. i’ll look into this. it is due to get some basic qt knowledge at least.

Well, that’s embarrasing. I’ve tried using this flag before. Must have done something wrong it seems.

Thank you!!

@cur10us you should mark Bob’s answer as the ‘solution’ so future lurkers know there’s a definitive answer…

sorry for late response. i can’t seem to find how to mark an answer as the solution

OK, I did it. Looks like there was a plugin setting that changed a version ago, hiding the option.