Image is not appearing in menuItem

27 views
Skip to first unread message

likage

unread,
Jun 21, 2017, 5:59:17 PM6/21/17
to Python Programming for Autodesk Maya
I have created a shelf icon using `shelfbutton` and I am adding a drop down menu which is created using the `popupMenu` and `menuItem`.
Good news is that, everything is working as I expected it to be.

This is not a biggie but when I tried to incorporate the command `image (-i)` flag for menuItem, it seems that the image is not loading at all.

shelfButton
   
-enableCommandRepeat 0
   
-enable 1
   
-width 34
   
-height 34
   
-label "Quick Access"
   
-image "quick_access.png"
   
-style "iconOnly"
   
-marginWidth 1
   
-marginHeight 1
   
-sourceType "python"
    popupMenu
-b 1;
        menuItem
-stp "python" -i "/user_data/model_picker.png" -l "Model Picker" -c "import model_picker; model_picker.main()";

For the image path, I did try using `"model_picker.png"` and making sure that the image is in the icons folders. Also no errors are thrown when I run it, and so I am not sure if my images does gets called, or perhaps there are something that I have did wrongly.

Any ideas?

Andrew Hazelden

unread,
Jun 22, 2017, 10:54:40 AM6/22/17
to Python Programming for Autodesk Maya
As a disclaimer, I haven't tried embedding a menuItem image before in a shelfButton entry. I have only used a menuItem in my own projects for actual "Menubar" based entries so I can't comment on how it would work or look when attached to a shelfButton. :-)

But, if your image is located inside one of the active Maya "XBMLANGPATH" icons path folders then you should be able to refer to the icon image using just the basename of the image like "model_picker.png" with no directory paths.

Regards,
Andrew Hazelden
Reply all
Reply to author
Forward
0 new messages