def updateChildren(self, nodeName, currentTranslator): """ update the translator UI, which consists of an optionMenuGrp and a frameLayout per translator, so that only the frameLayout corresponding to the currently selected translator is visible """ if not pm.layout(self._optionMenu, exists=True): # not built yet return fullpath = pm.layout(self._optionMenu, query=True, fullPathName=True) # get the grand-parent columnLayout gparent = fullpath.rsplit('|', 2)[0] # get the great-grand parent frame layout frame = fullpath.rsplit('|', 3)[0] try: pm.frameLayout(frame, edit=True, collapsable=False, labelVisible=False, borderVisible=False) except RuntimeError: # this is a little dirty: it will only succeed when attaching to AE pass children = pm.layout(gparent, query=True, childArray=True) # hide all frameLayouts but ours assert currentTranslator, "we should have a translator set by now" for child in children: # is it a frame layout? objType = pm.objectTypeUI(child) if objType == 'frameLayout': label = pm.frameLayout(child, query=True, label=True) # turn collapsable and label off if showAllTranslators: pm.frameLayout(child, edit=True, collapsable=False, labelVisible=True, visible=True) else: pm.frameLayout(child, edit=True, collapsable=False, labelVisible=False, visible=(label == currentTranslator))
def get_shelves(cls): """ Return an array of all shelves, as Shelf objects. """ labels = pm.tabLayout(gShelfTopLevel, q=True, tabLabel=True) shelves = pm.tabLayout(gShelfTopLevel, q=True, childArray=True) results = [] for idx, (shelf, label) in enumerate(zip(shelves, labels)): if pm.objectTypeUI(shelf) != 'shelfLayout': continue results.append(cls(shelf, label)) return results
def buttons(self): if self._buttons is not None: return self._buttons # The shelf needs to be loaded to get this info. self.load_shelf() try: buttons = pm.layout(self.path, q=True, childArray=True) except RuntimeError: # This raises RuntimeError if the shelf no longer exists. return [] if buttons is None: return [] self._buttons = [] for shelf_button in buttons: if pm.objectTypeUI(shelf_button) == 'shelfButton': self.buttons.append(shelf_button) elif pm.objectTypeUI(shelf_button) == 'separator': self.buttons.append(separator) return self._buttons
def updateChildren(self, nodeName, currentTranslator): """ update the translator UI, which consists of an optionMenuGrp and a frameLayout per translator, so that only the frameLayout corresponding to the currently selected translator is visible """ if not pm.layout(self._optionMenu, exists=True): # not built yet return fullpath = pm.layout(self._optionMenu, query=True, fullPathName=True) # get the grand-parent columnLayout gparent = fullpath.rsplit('|', 2)[0] # get the great-grand parent frame layout frame = fullpath.rsplit('|', 3)[0] try: pm.frameLayout(frame, edit=True, collapsable=False, labelVisible=False, borderVisible=False) except RuntimeError: # this is a little dirty: it will only succeed when attaching to AE pass children = pm.layout(gparent, query=True, childArray=True) # hide all frameLayouts but ours assert currentTranslator, "we should have a translator set by now" for child in children: # is it a frame layout? objType = pm.objectTypeUI(child) if objType == 'frameLayout': label = pm.frameLayout(child, query=True, label=True) # turn collapsable and label off if showAllTranslators: pm.frameLayout(child, edit=True, collapsable=False, labelVisible=True, visible=True) else: pm.frameLayout(child, edit=True, collapsable=False, labelVisible=False, visible=(label == currentTranslator))
def makeShelfButton(cls, name, command, icon, annotation='', *args, **kwargs): """ """ myPlatform = platform.system() if myPlatform.startswith('Win'): icon = icon.replace('\\', '/') try: currentShelf = pm.mel.eval('tabLayout -q -st $gShelfTopLevel;') # find the button if it already exists and delete it buttonArray = pm.shelfLayout(currentShelf, query=True, childArray=True) if buttonArray: items = [ item for item in buttonArray if pm.objectTypeUI(item) == 'shelfButton' ] # get only shelfButtons, just in case for i in items: label = pm.shelfButton(i, query=True, label=True) if label == name: pm.deleteUI(i) pm.setParent(currentShelf) pm.shelfButton(label=name, annotation=annotation, image1=icon, command=command) except: lcUtility.Utility.lc_print_exception( message='Something went wrong making the shelf icon')