def selectedItems(self): """:return: list of all selected items as strings, or an empty list if nothing is selected""" try: return noneToList(self.p_selectItem) except RuntimeError: return list()
def selectedIndices(self): """:return: tuple of all selected 1-based indices, or an empty tuple if there is nothing selected""" try: return tuple(noneToList(self.p_selectIndexedItem)) except RuntimeError: return tuple()
def itemArray(self): """:return: An array of our menuItems :note: This method worksaround a maya 2011 problem that makes it impossible to properly wrap menuItems with short names as returned by p_itemArray""" return [ MenuItem(name="%s|%s" % (self, i)) for i in noneToList(self.p_itemArray) ]
def selected_namespaces(self): """:return: list(Namespace, ...) list of Namespace objects which have been selected""" out = list() for item_name in noneToList(self.p_selectItem): if item_name == self.kSelectedNodes: continue # END skip sel node special item ns = Namespace(item_name) out.append(ns) assert ns.exists(), "Selected namespace did not exist: %s " % ns # END for each item return out
def children( self, predicate = lambda x: True ): """:return: list of child namespaces :param predicate: return True to include x in result""" lastcurrent = self.current() self.setCurrent( ) out = [] for ns in noneToList( cmds.namespaceInfo( lon=1 ) ): # returns root-relative names ! if ns in self._defaultns or not predicate( ns ): continue out.append( self.__class__( ns ) ) # END for each subspace lastcurrent.setCurrent( ) return out
def update(self): """Call to force the element to update according to the contents of the scene""" curItems = noneToList(self.p_selectItem) self.p_removeAll = 1 # add all items according to the scene and the configuration if self._show_selected: self.p_append = self.kSelectedNodes for ns in RootNamespace.children(): self.p_append = ns # END for each namespace in scene # reselect previous items for sli in curItems: try: self.p_selectItem = sli except RuntimeError: pass
def children( self ): """ :return: children of this layout """ childnames = mutil.noneToList( cmds.layout( self, q=1, ca=1 ) ) # assure we have long names to ensure uniqueness return uibase.wrapUI( [ "%s|%s" % ( self, c ) for c in childnames ] )
def uses_selection(self): """:return: True if the user wants to handle selected nodes""" return self.kSelectedNodes in noneToList(self.p_selectItem)
def children(self): """ :return: children of this layout """ childnames = mutil.noneToList(cmds.layout(self, q=1, ca=1)) # assure we have long names to ensure uniqueness return uibase.wrapUI(["%s|%s" % (self, c) for c in childnames])
def items(self): """:return: list of currently available items""" return noneToList(self.p_allItems)
def itemArray(self): """:return: An array of our menuItems :note: This method worksaround a maya 2011 problem that makes it impossible to properly wrap menuItems with short names as returned by p_itemArray""" return [MenuItem(name="%s|%s" % (self, i)) for i in noneToList(self.p_itemArray)]