Shelf Button Name Lost On Restart

Hi,
I'm making this shelf and one of the button's icon image changes when you click it. It does this by checking to see what the current icon image is and then changing approprietly:

shelfButton -q -image NameofButton;

Unfortunately when I restart Maya it stops working because it can't find "NameofButton". Any suggestions?

Thanks

Yes see button names dont get passed to the shelf save routines and its apin to hack them there but its possible.

Ok, so how would you do it?

So, I figured out what to do so I figured I'd post it in case anyone was searching this. Pretty easy actually, when Maya saves a shelf it goes into your user shelves directory(which you can find using print (internalVar -ush); ). It doesn't save the button names but you can just add them in manually to the file there and it works fine.

Yes byt tis has a porblem... if you add stuff to the shelf maya may decide to fix the name again.

Ya your right, I didn't realise until I closed and reopened maya for a second time(because it saves the shelf everytime you close maya properly). So I made the shelf file read-only, not the greatest solution but I'm the only using this script and all it does is comes up with a warning that it can't save over the read-only file.

Yes but you can remake the save routines to incorporate the name!

That'd be cool, how do you do that?