Alright, I had to put a unique name on the button before it would let me use the -ex querry. I really wish all items in Maya could be querried by any number of ways like shelfButton -ex -l "myStupidButton". However for now I found that if I name the item explicitely, I can querry it.
you can query any UI item in the same way, but the problem with shelves is that the UI name isn't stored by maya in the shelf.mel file. However, I've used the docTag to great effect here. If you assign a shelf button a docTag string, then you can reliably query if a shelf button exists or not. Its quite cool when your scripts have dynamic shelf buttons. Its also useful to attach right-click popup menus to them for extra options, without taking up an extra shelf button.
and then i have a proc that goes through all shelf buttons, queries their docTags, and returns the UI name, of the button that matches. Then once I know the name of the button, I can parent a popMenu to that UI control, with something like:
I tried to give a shelfButton a name, not through the docTag. I then parented a popupMenu to the shelf button. It always worked for the current session of maya; however, when I loaded Maya again and tried the shelfButton's popupMenu no longer exists. I am guessing that it needs to be embedded into the the shelfButton command somehow or explicitily written to the shelf file.
yeah man, thats why I'm saying use the docTag. the docTag is stored when the shelf is saved, on maya exit. so you need to write a proc that on startup, goes through all shelf buttons, finds the button with the specific docTag, and returns that button's UI name.
you can't embed the shelf button name into the file, because maya re-writes it everytime you save shelves. So as far as I see it, this is the easiest way to do it. This way you can also have shelf buttons that change icons when clicked (for example, I have written an autosave script, that saves a scene to a temp file, after a certain number of events have happened. the shelf button i've made for it, shows whether the script is enabled or not)
I know this thread is SUPER old, but this is a last ditched effort to get an answer. ive been struggling with this for about a year when I have time to work on it. you actually tweaked my interest when you mentioned that with -dtg you could toggle icons of a shelf button using this flag. ive tried over and over and just dont seem to be able to get it to work. [looking for a solution with MEL, I dont do Python. im just a lowly animator, not great with code]
would you be able to give me an example of a script that does this? I understand what you wrote, but I cant figure out how to write it.
im trying to query the button I just clicked, then toggle its icon to display the state of the object that is associated to this button.
I am not expecting a reply as this is SO old. but if I get one…oh boy, you will make my day!